![]() |
NewsPro FAQ |
The following are a few questions and answers that have either been extremely frequently asked, or that would just be generally useful knowledge. Many of these items are answers to questions asked by users in the NewsPro forum - these items are copied directly, and have the original questions quoted above them.
| |
[Add a New Answer in "NewsPro FAQ"] | |
![]() |
![]() How do I use my own date format, or do any custom date stuff? |
To do this, you can use the time variables that NewsPro generates automatically. Use these as you would any other variable (i.e. $newsname). The variables are as follows: $Year $Month_Day (Day of the month) $Week_Day (Number representing day of week. Sunday = 0, Saturday = 6) $Week_Days[$Week_Day] (The full name of the current weekday) $Month (Number of the current month, using the method computers count by: January = 0, December = 11) $ActualMonth (Number of the current month, as humans count: January = 1) $Months[$Month] (Full name of the current month) $Hour $Minute $Second $Time_Zone $AMPM (equal to either AM or PM, and only if you have enabled AM/PM times in Advanced Settings)elvii@amphibian.hypermart.net | |
[Append to This Answer] | |
![]() |
![]() How do I make it necessary for news to be validated before it gets posted? |
First, a warning. This method works just fine for sites which do not use any of NewsPro's advanced features. If you are using any of the following features, unvalidated news will be shown in the information produced by these features: - Headlines - E-mail Notification - My Netscape Channel If you use these features, there is currently no way to allow pre-validation of news. Edit npconfig.pl. Add 'uservar1' (or any other variable, I will use uservar1 as an example here) to @formfields. Add the following lines beneath: $FormFieldsName{'uservar1'} = "Validation"; $FormFieldsCustom{'uservar1'} = qq~ Required. <input type="hidden" name="uservar1" value="$UserPermissions{$Cookies{'uname'}}> ~; $DisableModify{'uservar1'} = 2; Now edit ndisplay.pl, sub DoNewsHTML. Around your existing news style settings, insert: $newshtml = ""; if ($uservar1 > 1) { # existing DoNewsHTML } Example: sub DoNewsHTML { # DO NOT REMOVE THIS LINE <BeginEdit> $newshtml = ""; if ($uservar1 > 1) { $newshtml = qq~ <p><strong><font color="#ff0000">$newssubject</font> </strong><small>Posted $newsdate by <a href="mailto:$newsemail"> $newsname</a></small><br> $newstext </p> ~; } # DO NOT REMOVE THIS LINE <EndEdit> } Now, when basic-level users post, their news will NOT be immediately displayed. Webmaster or High level users must go to Modify News. Submitted but unvalidated items will appear there. You must change the number in the box marked "Validation" to 3. Once you have changed that and news is built, the news item will be displayed.elvii@amphibian.hypermart.net | |
[Append to This Answer] | |
![]() |
![]() How can I use icons to show different types of news items? |
> Is there anyway that I can select like an image to use and then have it in
> For example, a news story would have an icon of a newspaper.
> Is there anyway I can do this-other than using the glossary? Depends where you want the image. If you want it within the news text, you have two options:
If you want a separate field for the icon, then you'll have to add a field to newspro by editing npconfig.pl. In npconfig.pl, add 'uservar1' to @formfields (if uservar1 is taken, just use another variable). Add the line
Then, edit sub DoNewsHTML in ndisplay.pl.
Now place all your icons in the directory your news page is in (or edit the <img src> tag to reflect their actual path). When submitting news, enter the name of the icon without the .gif at the end and it will be displayed. No image will be displayed if you leave the field blank. If you want, you could also use a list box to select an image instead of a text field. Just set the HTML code for a listbox called uservar1 using the $FormFieldsCustom method described in npconfig.pl. elvii@amphibian.hypermart.net | |
[Append to This Answer] | |
![]() |
![]() How can I modify change the name displayed with a news post without creating a new user? |
> Heyas, > This is my problem. Every once and a while, someone submits a news
> Okay, this is my question. Today, someone submitted a News Article. Now,
> So, if I want the author to appear as if someone else wrote it, I have to
There is no way to modify $newsname - it will ALWAYS be your username. $newsname is also what the script uses internally to see who posted a news item, and setting it to your username is hard-coded into the script. That said, what you can do is simply create your own "Display Name" field and not use $newsname within your news.
elvii@amphibian.hypermart.net | |
[Append to This Answer] | |
![]() |
![]() How much data can NewsPro handle? |
> Despite the fact that it wasn't designed to handle that kind of volume,
> Thanks for your time and I look forward to NewsPro 3.0! This script was originally designed for my personal use, or in other words something like two-three items/week. It's changed a lot since then :) By design, I didn't mean technical design but rather options and features. Monthly archiving IS pretty useless when you post large amounts of news. What I meant by design is that most sites which post huge amounts of news are generally going to require something to be custom-programmed - for that matter, most sites which post that much news employ a full-time programmer! Anyway - there are no set limits on anything. There are, however practical limits. These occur for a few reasons, the biggest being that NewsPro is not particularly fast (because I don't know how to make it fast!) and that text databases are not a good way of storing large amounts of data. What are these practical limits? Well, I was interested too, so I tested :) I took the newsdat.txt from the working demo on this site, which is about 250 KB and contains roughly 950 items. I opened up and did a lot of copying and pasting, duplicating those news items enough times to make a 11 MB newsdat.txt which contains about 30,000 news items. Then I installed a copy of newspro (version 3) on my own computer, and copied in this newsdat.txt. For those who need all the info, my computer is a Celeron/400 running Windows 95 (not a good server OS!) along with Apache for Windows as the web server and ActivePerl running the CGI. Building news, including monthly archives, took 1 minute. This is pretty much unmanageable, especially if you post often enough to create 30,000 news items. However, not too many people are going to write that much news, and if they do, they won't be using a Celeron running Windows 95 as their web server. Even if you post 100 news items a day (a LOT), it will still take about a year to accumulate 30,000 news items. In this situation, what you could do is every 3 months or so save your archives as static HTML files (they're not going to change as new items are posted...) and delete all your old news items. I wrote a lot! Needed to know this stuff though. Actually, I think I'll post this to the FAQ.
| |
[Append to This Answer] | |
![]() |
![]() When I try to edit archive files generated by NewsPro, my server won't let me. Why? |
> Hey, > Great program, it's made upating my site 1000 times easier. > I'm having a small problem with the Archiving feature however. I have
> However, when I go to access the file in my browser it says that i am not
> Here's the address of the archive:
> Thanx > Matt Holme Yes, this is something that happens on many servers. I'll try and give a basic explanation:
Anyway - the problem is that the web server, and therefore NewsPro, runs as user "nobody". By default, the files it creates are chmod 644 - in other words, it can read & write, all others (incl. you) can only read. There are a couple of ways around this. Many servers will not let you modify the file, but WILL let you delete it. If your server allows this, you can download the file, delete it from the server, re-upload, and chmod it 666. If your server doesn't, then your best bet is to download a program like the CGI Commander from CGI City (http://www.icthus.net/CGI-City/). All this does is lets you execute simple UNIX commands as the web server (make sure you disable it when not using it, as there are simple UNIX commands to delete all your files!). Using this, type in
| |
[Append to This Answer] | |
![]() |
![]() How can I display the date above all the day's news items? |
To do this, you must first change the date format to display only the date, not time. This can be done via the Advanced Settings page. Set all the time display variables to 1 except for Display_Time and Display_Time_Zone, set them to 0. Of course, you can disable the year or weekday if you'd like, just keep time and time zone off. Then, replace DoNewsHTML in ndisplay.pl with the following. Of course, change it to reflect your desired news style. sub DoNewsHTML { # Makes $newshtml empty. $newshtml = ""; # Begin by checking if the last date printed is the same as this date. # This uses NewsPro's internal isNewDate subroutine # If the current date is different from the last one, print it if (&isNewDate) { $newshtml .= qq~<h2><font color="#ff0000">$newsdate</font></h2>~; } # That's it for printing the date! Easy! Now just go on and print the news # (without the date, of course). Notice the use of .= rather than = $newshtml .= qq~ <p><strong>$newssubject</strong><small> Posted by <a href="mailto:$newsemail">$newsname</a></small><br> $newstext</p> ~; } As you can see, achieving something like this is quite simple. Note that the script always generates the HTML in order from most recent news to least recent news (exception: some of the dynamically generated viewnews.cgi pages, such as search, only generate a small subset of the news and don't necessarily do so in that order). Also, many sites with a lot of news like to have the date above all the day's news, but each news item would include the time of day it was posted. This too is possible, because the routine used to generate the date sets quite a few variables, such as $Hour, $Minute, $Second, and $Time_Zone. So, to achieve the style with the news above and the time with every news post, use the following to print out the news: $newshtml .= qq~ <p><strong>$newssubject</strong><small> Posted by <a href="mailto:$newsemail">$newsname</a> \@ $Hour:$Minute</small><br> $newstext</p> ~; Notice the @ sign is "escaped" as \@. That's what you have to do with many characters writing Perl. The full list of date/time variables: $Second, $Minute, $Hour, $AMPM, $ActualMonth, $Month_Day (the date), $Week_Day (counting from 0: Sunday is 0, Saturday 6), $Year, and $Time_Zone. elvii@amphibian.hypermart.net | |
[Append to This Answer] | |
![]() |
![]() When I log in, NewsPro sends me to a page on the wrong server (the URL it thinks it's at is incorrect). How can I fix this? |
To fix this, simply edit newspro.cgi (and viewnews.cgi) and follow the instructions in the Server Problems Workarounds section near the beginning of the script file. elvii@amphibian.hypermart.net | |
[Append to This Answer] | |
![]() |
![]() How can I get the e-mail addon to work with BLAT on NT? |
I had exactly the same problem and have hacked the relevant code in the Perl script. I modified the subroutine 'SendListEmail' in the file npa_email.pl thus: #Note : all original variables from the Advanced settings are as in # the original script # A temporary file is created in c:\temp and then blat sends that # so alter the path if you are working from elsewhere sub SendListEmail { local ($emailtext) = @_; my ($NT_mail_program); my ($NT_mail_params); &LoadEmailList; $emailbcc = join(',', @emaillist); # Add Control Z to end of mail text and add to temporary file $emailtext .= "©Z"; open(contents, ">> c:\temp\tmp$$"); print contents $emailtext; close(contents); # set up Blat and parameters $NT_mail_program = $NPConfig{'SendmailPath'}; $NT_mail_params = " c:\temp\tmp$$ -f $NPConfig{'EmailFrom'} -t $NPConfig{'EmailTo'} -s \"News Update\" -b $emailbcc "; # Execute blat system($NT_mail_program $NT_mail_params); } # End of subroutine Hope this helps Owen Parry University of Wales, UK o.parry@wales.ac.ukelvii@amphibian.hypermart.net | |
[Append to This Answer] |
|