Linking to Specific Tag Archive
Posted: 24 September 2008 07:11 AM   [ Ignore ]
Newbie
Rank
Total Posts:  1
Joined  2008-09-24

I have a list of my tags on my blog index page:

<div id="categories">
  <
h3>Browse by Category</h3>
  <
ul>
  
{exp:tag:cloud weblog="my_weblog"}  
    
<li><a href="{path=blog/archives}">{tag}</a></li>
  
{/exp:tag:cloud}
  
</ul>
</
div>

I want to link them through to my archives template and bring up only the entries with the particular tag.

1. How does the link path need to read on the code above?
2. Does it make more sense to setup a separate tag archive template or is it easy enough to do in the archive template I already have setup? If the latter, how does the tag entries expression need to read there (with the variables it needs to pull in, etc.)

Hope that makes sense and my apologies if these are rudimentary questions… I’m very new to EE.

Profile
 
 
Posted: 25 September 2008 06:43 AM   [ Ignore ]   [ # 1 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  3356
Joined  2006-10-18

Hi astuteo, smile

First of all, you’ll need to properly set up the Tag Cloud. smile
It appears you’ve chosen you want them to display as a list instead of a cloud, which is fine… so here’s what it should look like:

<div id="categories">
  <
h3>Browse by Category</h3>
  <
ul>
{exp:tag:cloud weblog="my_weblog"
 
<li><a href="{path=blog/tag_archives/tag}{websafe_tag}">{tag}</a></li>
{/exp:tag:cloud}
  
</ul>
</
div>

Now, of course, the template path is up to you, but here’s what’s required for each part/segment of that path: smile

{path=blog/tag_archives/tag}{websafe_tag}

blog - Nothing special… just the name of the template group.
tag_archives - Template name - what’s special about this is you use the Tag:Entries loop to display your entries, not Weblog:Entries - more below…
tag - The ‘tag’ part of the path is NOT a template, it is only a trigger/marker in the URL so that the Tag:Entries template knows where the Tag is in the URL
{websafe_tag} - The {websafe_tag} variable parses a URL-Friendly Tag so that it can be linked to “safely”

Which brings me to the next issue: Tag Entries List
Tag:Entries Documentation

Because the Weblog:Entries loop cannot determine which entries to display by the Tag in the URL, we have the Tag:Entries loop, which basically mimics the Weblog:Entries loop. Pretty much every variable and parameter available in Weblog:Entries is available for use in Tag:Entries. Here’s a sample:

<h1>{exp:tag:tag_name}</h1
  
{exp:tag:entries orderby="entry_date" sort="asc" limit="20" paginate="bottom"
  
<h2>{title}</h2
<
p>{body}</p
  
{paginate} 
<p>{pagination_links}</p
{/paginate} 
  
{
/exp:tag:entries}

 Signature 
Profile