Small How-tos

This forum spearheads the effort to fill out and complete the Coranto Docs Wiki. Announcements of new docs added will be posted here.
There's a lot that needs to be put together... want to help? Inquire within.

Moderators: Spunkmeyer, Dale Ray, SrNupsen, Bluetooth, Jackanape

Small How-tos

Postby Lumberjack » Thu Jan 11, 2007 3:19 pm

I have quite a few saved somewhere, I'll have a look when I get home.

EDIT: found a few, hope they are useful.
EDIT2: ah, thanks for splitting this topic off :)

These are a few small tips for styles etc that I found useful and deemed worthy enough to save, hehe! There were quite a few more on the old site but unfortunately I think they are lost now.
Last edited by Lumberjack on Fri Jan 12, 2007 10:17 am, edited 2 times in total.
Lumberjack
 
Posts: 555
Joined: Wed Jan 10, 2007 7:22 pm
Location: Oxford, UK

Postby Lumberjack » Thu Jan 11, 2007 7:06 pm

Alternating background colours - easy By L0rdPhi1

You can acheive alternating background colours by placing the following code in the top of your news style.

<PerlCode>
@OurColours = qw(#dddddd #eeeeee); # define the colours
$SwitchColour = $OurColours[($NextColour++ % @OurColours)];
</PerlCode>

Note that if you want to use more then two colours you can add more values to the OurColours array in the above code.

After adding and adjusting the above code use the variable <Field: SwitchColour> where you want the colour to be placed in your news style.

Example: <td bgcolor="<Field: SwitchColour>">
Lumberjack
 
Posts: 555
Joined: Wed Jan 10, 2007 7:22 pm
Location: Oxford, UK

Something interesting which I'd forgotten..

Postby Lumberjack » Thu Jan 11, 2007 7:08 pm

Reset a lost password By elvii

To reset a forgotten password (not recover, as that is impossible), download nsettings.cgi, and add the following line to the top of it.
resetpass``xusername, replacing username with the loginname of the user you'd like to have the pass reset for.
Next time they login, whatever pass they use will be set as there new one.
Last edited by Lumberjack on Sun Jan 14, 2007 12:54 pm, edited 1 time in total.
Lumberjack
 
Posts: 555
Joined: Wed Jan 10, 2007 7:22 pm
Location: Oxford, UK

Postby Lumberjack » Thu Jan 11, 2007 7:08 pm

Use Coranto on one server, have news on another By Michael R. Tomkins

To use Coranto on one server, and include the news on another - you can use one of several things.
Firstly - a PHP include if you can, simply using
<?php include("http://your.site.com/news.txt"); ?>
or whathaveyou.
Secondly - you can use a javascript include, but, you have to add some stuff to the very bottom of the style (Administration->Edit News Styles) so that it will work properly.

<PerlCode>
$newshtml =~ s/\"/\&quot;/g; # escape quotes
$newshtml =~ s/[\n\r]//g; # remove line feeds
$newshtml = qq~document.write("$newshtml");~;
</PerlCode>

then add

<script src="http://your.site.com/news.txt"></script>
<noscript>To see the latest news, you need a browser that supports JavaScript.</noscript>

obviously putting the right url in there.
Lumberjack
 
Posts: 555
Joined: Wed Jan 10, 2007 7:22 pm
Location: Oxford, UK

Re: Something interesting which I'd forgotten..

Postby GabeT » Sun Jan 14, 2007 3:42 am

Lumberjack wrote:Reset a lost password By elvii

To reset a forgotten password (not recover, as that is impossible), download nsettings.cgi, and add the following line to the top of it.
resetpass` ` xusername, replacing username with the loginname of the user you'd like to have the pass reset for.
Next time they login, whatever pass they use will be set as there new one.


Your code has a space in it, it should be "resetpass``xUsername" or it will not work.
GabeT
 
Posts: 86
Joined: Thu Jan 11, 2007 12:35 am
Location: Albuquerque, NM


Counting categories

Postby Lumberjack » Sun Jan 14, 2007 12:37 pm

Counting categories

This is a complicated one. It uses purely PerlCode in a style to set up the counted categories during build. Then it uses a custom template to generate the count.txt file. Here is the idea:

The style

Create a style count:

Code: Select all
<PerlCode>
$CategoryCounter{$Category}++;
if (!defined($CountItem_time{$Category}) or $newstime > $CountItem_time{$Category}) {
   $CountItem_time{$Category} = $newstime;
   $CountItem_id{$Category} = $newsid
};
$CategoryCountLink{$Category} = '/find.shtml?id='.$CountItem_id{$Category}.'&style=Maginot';
</PerlCode>

Note: the link using find.shtml is optional, it uses Parahead's addon QueryFetcher *

The template

Next create a template count that will include the categories you want:
Code: Select all
C1: <a class="nav" href="<Field: CategoryCountLink{"c1cars"}>" title="Latest"><Field: CategoryCounter{"c1cars"}> cars</a><br>
C2: <a class="nav" href="<Field: CategoryCountLink{"c2cars"}>" title="Latest"><Field: CategoryCounter{"c2cars"}> cars</a>, <a class="nav" href="<Field: CategoryCountLink{"c2skins"}>" title="Latest"><Field: CategoryCounter{"c2skins"}> skins</a><br>
TDR: <a class="nav" href="<Field: CategoryCountLink{"tdrskins"}>" title="Latest"><Field: CategoryCounter{"tdrskins"}> skins</a><br>
GTA1: <a class="nav" href="<Field: CategoryCountLink{"gtacars"}>" title="Latest"><Field: CategoryCounter{"gtacars"}> cars</a><br>
GTA2: <a class="nav" href="<Field: CategoryCountLink{"gta2cars"}>" title="Latest"><Field: CategoryCounter{"gta2cars"}> cars</a><br>
GTA3: <a class="nav" href="<Field: CategoryCountLink{"gta3skins"}>" title="Latest"><Field: CategoryCounter{"gta3skins"}> player skins</a><br>
GTA:VC: <a class="nav" href="<Field: CategoryCountLink{"vccars"}>" title="Latest"><Field: CategoryCounter{"vccars"}> cars</a>, <a class="nav" href="<Field: CategoryCountLink{"gtavcskins"}>" title="Latest"><Field: CategoryCounter{"gtavcskins"}> skins</a>
Crashday: <a class="nav" href="<Field: CategoryCountLink{"crashdaycars"}>" title="Latest"><Field: CategoryCounter{"crashdaycars"}> cars</a>, <a class="nav" href="<Field: CategoryCountLink{"crashdayskins"}>" title="Latest"><Field: CategoryCounter{"crashdayskins"}> skins</a>

I have here used the variables set up in the Perl style.. hopefully you can see how to rework this for your needs.

The profile


Finally create the profile that will drive the building of this count.txt file, using the style count and the template count.tmpl that you've just made. You can include all categories to future proof the template for addition of more categories. It will probably slow down build news, so you can just limit to the categories you have selected in the template.
I'm not sure if the sort order makes a difference, but I have it set to
Unsorted (Reverse chronological) for interlinking


*Actually it is broken on my site as viewnews.cgi doesn't seem to work. I would like another solution if someone knows it (not involving Maginot static!)
Lumberjack
 
Posts: 555
Joined: Wed Jan 10, 2007 7:22 pm
Location: Oxford, UK

Re: Something interesting which I'd forgotten..

Postby Lumberjack » Sun Jan 14, 2007 12:55 pm

GabeT wrote:Your code has a space in it, it should be "resetpass``xUsername" or it will not work.

Heh, thanks! I just copied it off the saved page from years ago, I assumed it would all be correct :D - corrected.
Lumberjack
 
Posts: 555
Joined: Wed Jan 10, 2007 7:22 pm
Location: Oxford, UK


Return to Documentation Project

Who is online

Users browsing this forum: No registered users and 1 guest

cron