cat archive tag to list subcats of given parent?
Posted: 13 April 2007 06:23 AM   [ Ignore ]  
Lab Assistant
Avatar
RankRank
Total Posts:  126
Joined  03-23-2007

Am going round in circles trying to finish my first EE site…please help if you can!

Is it possible to get the category_archive tag to display a list of subcategories for a given parent category (that would be == url segment 2)?

Thanks!

Profile
 
 
Posted: 13 April 2007 07:06 PM   [ Ignore ]   [ # 1 ]  
Moderator
Avatar
RankRankRankRankRankRankRankRank
Total Posts:  32861
Joined  05-14-2004

The category archive’s entire function is really to output a list of all categories and entries belonging to each category.

So, without more of an explanation of what you want, it is hard to address. Can you describe what kind of display you want and on what kind of page? Perhaps then we can help to steer you in the right direction. =)

 Signature 
Profile
MSG
 
 
Posted: 18 April 2007 05:37 AM   [ Ignore ]   [ # 2 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  126
Joined  03-23-2007

Hi Lisa. Thanks for your reply and sorry for delay in responding…..

Actually, ignore my first post, I’ve just realised what I want to do is list titles of all other entries also tagged with the current entry’s subcategory - ie like an “also in this section” type panel. I want to include the current entry in the list too.

The current subcategory name would be in the url as segment4 (I have set up my prefs to be able to use cat names in urls with marker ‘category’), and I am passing the url segments to variables using the cat ID so that I can use those in my tags….like so:

<?php
// assign the url segment to a variable
$my_cat="{segment_2}";
$my_subcat="{segment_4}";

// check to the variable and assign the appropriate ID to another variable which we'll use in the weblog tag

switch ($my_cat)
{
case "reefdoctor":
$my_cat_id="20";
break;
case
"expeditions":
$my_cat_id="21";
break;
case
"join":
$my_cat_id="22";
break;
case
"science":
$my_cat_id="23";
break;
case
"resources":
$my_cat_id="28";
break;
case
"news":
$my_cat_id="31";
break;
case
"links":
$my_cat_id="33";
break;
case
"contact":
$my_cat_id="34";
break;

// add more cases here
}

switch ($my_subcat)
{
case "madguide":
$my_subcat_id="36";
break;
}

?>

{exp
:weblog:entries weblog="staticpages" category="<?php echo $my_cat_id ?>" limit="1" }

{categories weblog
="staticpages"}
{if category_description}
<h1>{category_description}</h1>
{/if}
{
/categories}

<h2>{title}</h2>
{body}

{
/exp:weblog:entries}

<ul id="category_entries">

{exp:weblog:entries weblog="staticpages" category="<?php echo $my_subcat_id ?>"}
<li><a href="{path="rd/resources/category/{segment_4}/{url_title}"}">{title}</a></li>
{/exp:weblog:entries}

</ul>

I am none too confident with writing php code so what I am not sure about is if I can do what I have done with assigning the $subcat variable (just copying what I was helped to do with the segment2 variable).

You can see what is happening at the moment here (down the foot of the page there is the generated list of entries for the current subcategory (madguide), but clicking the entry people doesn’t go anywhere…..have I done something weird with the path for these <li>‘s ?

Thanks for any assistance…

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 64938 Total Logged-in Users: 55
Total Topics: 81909 Total Anonymous Users: 39
Total Replies: 440313 Total Guests: 293
Total Posts: 522222    
Members ( View Memberlist )