Using conditional styles with viewnews.cgi

Discuss news styles, css code, and other Coranto customizations in here...the possibilities are endless, so have at it!

Moderator: Spunkmeyer

Using conditional styles with viewnews.cgi

Postby Dale Ray » Fri Jun 16, 2006 6:47 am

OK, I am sure that someone else has already thought of this but I am going to share anyway.

I have items from more than one category being collected by a profile/style combination to be displayed on a calendar. I want links to details from the calendar, but since they are different types of items the layout of the details and which fields are included should be different.

In my case the items are in different categories so at the top of my style I used this:
Code: Select all
<PerlCode>
if ($Category eq "One") {
$thisStyle = "styleOne";
} elsif ($Category eq "Two") {
$thisStyle = "styleTwo";
} else {
$thisStyle = "defaultStyle";
}
</PerlCode>


Then where the link code goes use:
Code: Select all
<a href="http://www.yoursite.net/coranto/viewnews.cgi?id=<Field: newsid>&amp;style=<Field: thisStyle>">Some Text to Display Here</a>


<Field: thisStyle> is replaced with the value set in the perlcode. You can now call viewnews with a style appropriate to the item.

Also, I always gut the template for viewnews.cgi so that it only contains:
Code: Select all
<Field: Content>


I then put all of the code for the web page that will be displayed with viewnews.cgi into the style and always include the style parameter when using viewnews.cgi.

This is just the way I like to do things, but I find it gives me more flexibility.
Dale Ray
User avatar
Dale Ray
 
Posts: 1001
Joined: Sun Jan 19, 2003 6:02 pm
Location: NW Indiana

Return to Customization

Who is online

Users browsing this forum: No registered users and 3 guests

cron