Creating a Site Map
Posted: 19 August 2004 08:27 AM   [ Ignore ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  779
Joined  12-01-2002

I’m creating a site map for a clients site. I want to be able to use the category_archive function, since this allows for new categories to be added overtime without my interference. The issue I’m having though is specifying the article location within the site map.

Currently, I have

{exp:weblog:category_archive weblog=“log” backspace=“6”}

{categories}
<h3>{category_description}</h3>
{/categories}

{entry_titles}
<a href=”{path=log/article}”>{title}</a><br />
{/entry_titles}

{/exp:weblog:category_archive}


Since in my system, each category has an associated template group, what I’d like to see is the path=log/article replaced with the category name.  So for category one path would be path=one/article, path=two/article etc. 

Basically, what I want is so that the EE Query might look something like this (this code doesn’t actually work)

{exp:weblog:category_archive weblog=“nahic” backspace=“6”}

{categories}
<h3>{category_description}</h3>
{/categories}

{entry_titles}
<a href=”{path={categories}/article}”>{title}</a><br />
{/entry_titles}

{/exp:weblog:category_archive}

This would then create a list like so:

<h3>Adolescent Health Data</h3>
<ul><li><a href=“http://nahic.ucsf.edu/index.php/data/article/adolescent_health_report_card/”>Adolescent Health Report Card</a><br />
</li>
<li><a href=“http://nahic.ucsf.edu/index.php/data/article/americas_adolescents_are_they_healthy_2003/”>America’s Adolescents: Are They Healthy? (2003)</a><br />
</li></ul>

<h3>Tools for State & Local Programs</h3>
<ul><li><a href=“http://nahic.ucsf.edu/index.php/tools/article/adolescent_health_tool/”>Adolescent Health Tool</a><br />
</li></ul>

Where the <h3> tag displays the category description or in my case the proper category name, but then the path displays the actual category (which matches the template name), in this case first “data” then “tools” respectively.

Is it possible to display the pulled “category_name” as part of the article path??  Has anyone come up with a DYNAMIC solution for this?

The only other option I can think of is to pull each category independently, which works ONLY until a new category comes along, then the template code would need to be changed.

Profile
 
 
Posted: 19 August 2004 12:40 PM   [ Ignore ]   [ # 1 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  7534
Joined  08-05-2002

If you have PHP on Output for this template you could use something like this, I believe:

{exp:weblog:category_archive weblog="weblog1" backspace="6"}

{categories}
<h3>{category_description}</h3>
<?php $categories[] = '{category_name}'; ?>
{
/categories}

{entry_titles}
<?php
$path
= '{path=data/article}';
$path =& str_replace('data',$categories[sizeof($categories) - 1], $path);
?>
<a href="<?php echo $path; ?>">{title}</a><br />
{/entry_titles}

{
/exp:weblog:category_archive}

 Signature 
Profile
 
 
Posted: 23 August 2004 07:37 AM   [ Ignore ]   [ # 2 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  779
Joined  12-01-2002

WOW! That’s impressive, and worked like a charmed. I added one more line, a strtolower to convert my category from “Data” to “data” and it’s a thing of beauty.  Thanks so much.

Now, just because I know it’s come up for me before and I want to be sure I understand… 

Basically EE variables can be used in PHP, if its defined during a regular EE statement, and the EE variable is quoted. Is that somewhat correct??

Profile
 
 
Posted: 23 August 2004 07:41 AM   [ Ignore ]   [ # 3 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  7534
Joined  08-05-2002

Yes, and if PHP is done on output, since we need all of the EE tags and variables parsed first to get the data in the PHP variables. 

 Signature 
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: 64907 Total Logged-in Users: 41
Total Topics: 81849 Total Anonymous Users: 36
Total Replies: 440051 Total Guests: 226
Total Posts: 521900    
Members ( View Memberlist )