Gossamer Forum
Home : Products : Links 2.0 : Customization :

Using an include only on the first level category.

Quote Reply
Using an include only on the first level category.
Hello,
I have a include question.
I want to use a include in Links2.0 to tie in my calendar.cgi events with the apporiate catergory in Links. So that if you are viewing the catergory "Arts" then at the bottom you will see the calendar events pertaining to "arts". Now i have the calendar scritpt all working to do this on an include on the Catergory.html template such as this:

<!--#include virtual="/cal/links-cal-display.cgi?action=display&Category=<%category_name%>"

And it works fine for the Categories...Only it tries to display events in the subcategories like "Arts/Poetry" because of the template. Now i don't want the calendar events pulled into the subcategories, only on the main categories....

How can i achieve this. I have looked in the all the files, nph-build, site_html_templates, and i get lost as to where the catagoies are being split.. and what to code if i find it..

any help out there????
Quote Reply
Re: Using an include only on the first level category. In reply to
you could create another template for the sub-catagories, check out this mod in the FAQ's

http://www.gossamer-threads.com/...es/Detailed/213.html

Hope that helps,
Ian

[This message has been edited by Nofatals (edited April 13, 2000).]
Quote Reply
Re: Using an include only on the first level category. In reply to
Thanks...
I had looked at that...but it seems that was to make different templates based on different categories. What i want is to only use one template on first level categories, and not on any other...Is there a subroutine that can sort them out? i guess i am not following how your suggestion will work for me. Will i have to name all my first level catergories in the if/then statment you posted? Is there no way to do it automatically sorting first levels out?

Thanks agian....
Quote Reply
Re: Using an include only on the first level category. In reply to
NoFatals has suggested a partial solution for your problem in terms of using the Multiple Category Template Mod...However, it does not completely solve your problem, since the Multiple Category Template Mod has the same template files for main categories and their designated sub-categories.

One suggestion is to do the following:

1) Add a new field called isSpecial as a Yes/No field in your category.def file. Follow the instructions in the FAQ about adding new fields to your existing links.db file...Use the script in that Topic, but change the following values:

links.db ===> categories.db
links2.db ===> categories2.db
links.def ===> category.def

2) Then edit your main categories to have "Yes" selected for the isSpecial field.

3) Then add the following codes in the sub site_html_category routine in the site_html_templates.pl file:

Code:
($rec{'isSpecial'} eq 'Yes') ? ($rec{'isSpecial'} = 1) : (delete $rec{'isSpecial'});

4) Then in your category.html file, put the following codes:

Code:
<%if isSpecial%>
<!--#include virtual="/cal/links-cal-display.cgi?action=display&Category=<%category_name%>"-->
<%endif%>

Hope this helps and works for ya.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.


[This message has been edited by AnthroRules (edited April 13, 2000).]
Quote Reply
Re: Using an include only on the first level category. In reply to
AnthroRules,

This may have been discussed before.

If you wanted to include different banner ads in each category. Using what you posted above I was thinking would it be possible to set a new field in the category like bannerad.
This would be using webadverts from http://awsd.com/scripts/webadverts/

When you set your categories up you could use the field bannerad to set the "zones".

A,B,C,D etc. or however you would like.
Then in your category.html use something like the following.

for ssi: <P ALIGN=CENTER><!--#exec cgi="zone_<%bannerad%>.pl"--></P>

for image: <A HREF="ads.pl?banner=NonSSI; zone=<%bannerad%>;page=<%ID%>"><IMG SRC="ads.pl?page=<%ID%>"></A>


Could even ad an additional field like isSSI yes/no

Then use:
<%if isSSI%><P ALIGN=CENTER><!--#exec cgi="zone_<%bannerad%>.pl"--></P><%endif%>
<%ifnot isSSI%><A HREF="ads.pl?banner=NonSSI;page=<%ID%>"><IMG SRC="ads.pl?zone=<%bannerad%>;page=<%ID%>"></A><%endif%>

Think something like this would work? Like I said it may have been done already but I am trying to think these things out loud. Smile

Larry




[This message has been edited by NewToThis (edited April 13, 2000).]

[This message has been edited by NewToThis (edited April 13, 2000).]
Quote Reply
Re: Using an include only on the first level category. In reply to
AnthroRules,
I have set up eveything as you suggested only i am not sure Exactly where to put the
Code:
($rec{'isSpecial'} eq 'Yes') ? ($rec{'isSpecial'} = 1) : (delete $rec{'isSpecial'});
you said it goes here
Code:
sub site_html_category {
# --------------------------------------------------------
# This rountine will build a page based for the current category.

return &load_template ( 'category.html', {
date => $date,
time => $time,
category => $category,
links => $links,
title_linked => $title_linked,
title => $title,
total => $total,
grand_total => $grand_total,
category_name => $category_name,
category_name_escaped => $category_name_escaped,
category_clean => $category_clean,
description => $description,
meta_name => $meta_name,
meta_keywords => $meta_keywords,
header => $header,
footer => $footer,
prev => $prev,
next => $next,
related => $related,
}
I tried several places in this code and none of it worked... where shoudl i place the snippet of code you sent?
Thanks
Alvy
Quote Reply
Re: Using an include only on the first level category. In reply to
Hello again.....
Ok...I have found the correct area to put the final bit of code.
Code:
sub site_html_category {
# --------------------------------------------------------
# This rountine will build a page based for the current category.
($rec{'isSpecial'} eq 'YES') ? ($rec{'isSpecial'} = 1) : (delete $rec{'isSpecial'});

return &load_template ( 'category.html', {

And fix the category.def file as such:
Code:
# Definition of your database file.
%db_def = (
ID => [0, 'numer', 5, 8, 1, '', ''],
Name => [1, 'alpha', 40, 75, 1, '', '^[\w\d/_-]+$'],
Description => [2, 'alpha', '40x3', 500, 0, '', ''],
Related => [3, 'alpha', 0, 255, 0, '', ''],
'Meta Description' => [4, 'alpha', 40, 75, 0, '', ''],
'Meta Keywords' => [5, 'alpha', 40, 75, 0, '', ''],
Header => [6, 'alpha', 40, 75, 0, '', ''],
Footer => [7, 'alpha', 40, 75, 0, '', ''],
isSpecial =>[8, 'alpha', 0, 25, 0, 'NO', 'NO|YES']
);
and updated my database to reflect that.
And put the ifSpecial statement in my category.html..

It still is not working...I am using the Enhanced Template.pm from the Resource area.
Would that affect this mod you wrote??
Or any other suggestions on this method...

Alvy

[This message has been edited by Alvy (edited April 15, 2000).]
Quote Reply
Re: Using an include only on the first level category. In reply to
1) If your goal (which you have not clearly stated in the first post you made in this Topic) is to use different banners in category pages, you should've read the Topics in this forum that discusses zones for WebAdverts...This has been discussed about five times in the past month.

2) The reason that the codes I provided you do not work is that you are mixing CASE SETTINGS in your fields and codes....

See the codes I provided you:

Code:
($rec{'isSpecial'} eq 'Yes') ? ($rec{'isSpecial'} = 1) : (delete $rec{'isSpecial'});

And do you see the field definition you added to the category.def file:

Code:
isSpecial =>[8, 'alpha', 0, 25, 0, 'NO', 'NO|YES']

Okay...do you see the problem?

If not and if you need it spelled out...

Change the following codes:

Code:
($rec{'isSpecial'} eq 'Yes') ? ($rec{'isSpecial'} = 1) : (delete $rec{'isSpecial'});

to the following:

Code:
($rec{'isSpecial'} eq 'YES') ? ($rec{'isSpecial'} = 1) : (delete $rec{'isSpecial'});

See, you have used NO and YES values for the isSpecial field in the category.def file. Welp, you need to match the cases in the conditional codes I provided for you that are added to the sub site_html_category routine.

Wink

Regards,


------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.
Quote Reply
Re: Using an include only on the first level category. In reply to
AnthroRules..
ouch...that stings....

1) I never mention Banner ads in my original post because that is not what i am doing..as is does state in my original post is that i want to tie my events calendar with top level categories..I am pulling in the events from my events calendar. that part is working as i have tested it by itself in a shtml file.
2) I know all my code is case sensitive and they all reflect "YES/NO" in the capital form ....in the database, in the category.def, and in the site_html_template.pl. And i just went back and DOUBLE checked it...

So... do you have any advise based on this?

alvy

Quote Reply
Re: Using an include only on the first level category. In reply to
Well, there are two potential problems:

1) Did you select YES for the main categories by modifying each of the main categories? If not..then you need to do that and then re-build your directory.

2) Are you sure that the following codes work in your SSI pages?

Code:
<!--#include virtual="/cal/links-cal-display.cgi?action=display&Category=<%category_name%>"-->

You may need to use the following codes:

Code:
<!--#exec cgi="/cal/links-cal-display.cgi?action=display&Category=<%category_name%>"-->

Other than that...I do not know the problem you are having with the codes.

Sorry...

Wink

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.
Quote Reply
Re: Using an include only on the first level category. In reply to
I have solved the problem that I wanted solved. (with the help of everyone in the forum and some REAL DIGGING to find the solution)

I wanted an include to pull in txt from somewhere else (my calendar script) and display information based on that catergory, but ONLY top level categories and NOT sub-categories.
Here is all the changes at once:

In category.def
1) I added the new field, (isSpecial), to the Database Definition: CATEGORIES
Code:
# Definition of your database file.
%db_def = (
ID => [0, 'numer', 5, 8, 1, '', ''],
Name => [1, 'alpha', 40, 75, 1, '', '^[\w\d/_-]+$'],
Description => [2, 'alpha', '40x3', 500, 0, '', ''],
Related => [3, 'alpha', 0, 255, 0, '', ''],
'Meta Description' => [4, 'alpha', 40, 75, 0, '', ''],
'Meta Keywords' => [5, 'alpha', 40, 75, 0, '', ''],
Header => [6, 'alpha', 40, 75, 0, '', ''],
Footer => [7, 'alpha', 40, 75, 0, '', ''],
isSpecial =>[8, 'alpha', 0, 25, 0, 'NO', 'NO|YES']
);
2. I used a radio feild for my isSpecial so I specified it here:
Code:
%db_radio_fields = (isSpecial =>'NO,YES' );
At this point you have to update your catergory database (catergory.db)to reflect the new feild.

Now in nph-build.cgi, in the area sub build_category_pages,
1. I added $isSpecial here
Code:
local ($description, $related, $meta_name, $meta_keywords, $header, $footer, $next, $prev, $isSpecial);
2. and add $isSpecial here AND changed the [2..7] to [2..8]:
Code:
($description, $related, $meta_name, $meta_keywords, $header, $footer, $isSpecial) = @{$category{$cat}}[2..8];

NOW in site_template_html.pl, added isSpecial => $isSpecial here:
Code:
sub site_html_category {
# --------------------------------------------------------
# This rountine will build a page based for the current category.

return &load_template ( 'category.html', {
date => $date,
time => $time,
category => $category,
links => $links,
title_linked => $title_linked,
title => $title,
total => $total,
grand_total => $grand_total,
category_name => $category_name,
category_name_escaped => $category_name_escaped,
category_clean => $category_clean,
description => $description,
meta_name => $meta_name,
meta_keywords => $meta_keywords,
header => $header,
isSpecial => $isSpecial,
footer => $footer,
prev => $prev,
next => $next,
related => $related,
build_links_per_page => $build_links_per_page,
%globals
} );

}
Lastly in used the if/endif statement in category.html in the Templates folder.
mine looks like this:
Code:
<%if isSpecial eq 'YES'%>
<!--#include virtual="/buncombe/events/cal/links-cal-display.cgi?action=display&Category=<%category_name%>"-->
<%endif%>
So that 'YES' is matching the feild isSpecial.
This is how i got it to work for me...so I am sure other variations on this theme will work too..

Thanks everybody!

Alvy