Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Globals: Category sensitive subnavigation?

Quote Reply
Globals: Category sensitive subnavigation?
Hi,

I want to have a subsnav of each category, that recognizes any subcategories and auto fills them into a format. The approach I have been taking is labor intensive and means updating this file whenever a sub-category is added. It seems that there is some way to get the system to recognize subcats and fill them in.

What I've been working on doing is something like this:
<%if Name eq 'articles'%>
<p>
<p><a href="/content/articles/big_issues/">Big Issues</a>
<p><a href="/content/articles/books/">Books</a>
<p><a href="/content/articles/culture_Fix/">Culture Fix</a>
<p><a href="/content/articles/events/">Events</a>
<p><a href="/content/articles/health/">Health</a>
<a href="/content/articles/news/">News</a>
<a href="/content/articles/travel/">Travel</a>
</p>
<%endif%>
<%if Name eq 'classifieds'%>
<p>
<a href="/content/classifieds/services/">Services</a> <br> <br>
<a href="/content/classifieds/mail_order/">Mail Order</a> <br> <br>
<a href="/content/classifieds/travel/">Travel</a> <br> <br>
</p>
<%endif%>

But this requires I manually edit this file every time I add a category. Is there some way to use the globals to get linksSQL 2x to automagically read the categories and fill it in? I don't want to use a seperate file or template set for each category, too much upkeep. (if my design changes, I ahve to edit all those files)

Details, Details. Smile (I don't know perl.)

Last edited by:

pugdog: Nov 27, 2001, 3:00 PM
Quote Reply
Re: [Evoir] Globals: Category sensitive subnavigation? In reply to
I'm wondering: is there some other IF statement that will allow all categories below the main category to use the same content?

In other words, instead of using:
<%if Name eq 'articles'%>
<%endif%>

Maybe there is some other IF statement. What's happening, is that I have a seperate navigation for the articles section, which has subcats, and a seperate navigation for the classifieds section, which has subcats. Using this <%if Name eq 'articles'%> only shows the artciles navigation when viewing the main articles section, not in the subcats within "articles".

Is there a way to list multiple categories in the IF statement? Like <%if Name eq 'articles',"travel"%> That could work.

Maybe this is a better approach.

Quote Reply
Re: [Evoir] Globals: Category sensitive subnavigation? In reply to
Talking to myself here Smile

Ok, what about something like:
<%if category eq 'articles'%>
<%include include_stories_nav.txt%>
<%endif%>

<%if category eq 'classifieds'%>
<%include include_classifieds_nav.txt%>
<%endif%>

But it doesn't work Frown What am I doing wrong?


Quote Reply
Re: [Evoir] Globals: Category sensitive subnavigation? In reply to
Isn't the category variable with a capital c (ie. Category, not category)?


Adrian
Quote Reply
Re: [brewt] Globals: Category sensitive subnavigation? In reply to
I tried both. Will try again and report. Smile
Post deleted by PaulW In reply to
Quote Reply
Re: [PaulW] Globals: Category sensitive subnavigation? In reply to
Ok, I tried this:

<%if Category eq 'articles'%>
<%include include_stories_nav.txt%>
<%endif%>

<%if Category eq 'classifieds'%>
<%include include_classifieds_nav.txt%>
<%endif%>

and nothing appears on the page.

If I use
<%if Name eq 'articles'%>
<%include include_stories_nav.txt%>
<%endif%>

I get the subnavigation within the category, but not the subcats.
I'm looking for a way to have the subcats be recognized by thier parent category. (not sure if I said that "properly", but I hope it explains what I'm looking for.)

The way I see it, I could use a different template set, but all I need to use is a different include file per category. I suppose i can fill out the

<%if Category eq 'articles'%>
<%include include_stories_nav.txt%>
<%endif%>

all the way through, but, I was hoping for a more elegant approach. Smile


Last edited by:

Evoir: Nov 27, 2001, 2:34 PM
Quote Reply
Re: [Evoir] Globals: Category sensitive subnavigation? In reply to
Hi,

Try:

<%if Category like 'articles'%>
<%include include_stories_nav.txt%>
<%elsif Category like 'classifieds'%>
<%include include_classifieds_nav.txt%>
<%endif%>

However, that means if articles appear anywhere in the category name, it will get included. May work depending on how you've named your categories.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Globals: Category sensitive subnavigation? In reply to
Is the reason <%if Category eq 'classifieds'%> isn't showing up because it's located in the include_footer template? (the <%if Name eq 'classifieds'%> showed up just fine in the include_footer template.)

Quote Reply
Re: [Evoir] Globals: Category sensitive subnavigation? In reply to
Hi,

No, the problem is Category eq 'classifieds'. It doesn't equal it exactly so it doesn't match and won't load the include in. If you use Category like, then as long as it contains the word it will match.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Globals: Category sensitive subnavigation? In reply to
but Category eq 'classifieds should work. There is a category names "classifieds" Unsure

Quote Reply
Re: [Evoir] Globals: Category sensitive subnavigation? In reply to
Hi,

I'll bet your category is called "Classifieds" -- note the capital C.

MySQL uses a case insensitive match, and Alex added "Like" to
give perl that similar search ability, but otherwise, to perl,

"category" does not equal "Category"

Just a thought.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Globals: Category sensitive subnavigation? In reply to
<scratching head>Crazy

nope, "classifieds" small c

Quote Reply
Re: [Evoir] Globals: Category sensitive subnavigation? In reply to
Hi,

Best way to debug this is do:

<%GT::Template::dump%>

at the bottom of your template and you will get a nice html table of all the tags and their values. That should point you in the right direction.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Globals: Category sensitive subnavigation? In reply to
Just a voice on this:

<%GT::Template::dump%>

Is one of the MOST USEFUL things you can do during debugging your templates or output. It can show you if what you _think_ is being sent is really being sent.




PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Globals: Category sensitive subnavigation? In reply to
Pugdog and Alex,

I just don't get it. how can this be helpful, can you explain more?
Quote Reply
Re: [Evoir] Globals: Category sensitive subnavigation? In reply to
Hi,

Try it out! =) Goto say home.html and add at the very bottom:

<%GT::Template::dump%>

and now goto page.cgi.

You'll see a nice list of all the template tags available on this page, and what their values are.

Cheers,

Alex
--
Gossamer Threads Inc.