Divine Blog

Linking to weblog template groups in EE

Posted: Apr 2008, Matt | In: Development & Expression Engine | Leave a comment

What if you're showing a list of entries, from more than one weblog, but you don't want each link that is created to go to the same template? How do you get EE to produce links to different templates depending on an articles particular weblog assignment?

Whilst recently following an example of producing an XML site map for google, I stumbled across a problem when it came to generating links.

We had created specialized template groups for each weblog we were using, and because of this, an article from the Projects weblog, with it’s unique attributes, could only be displayed using the template we had provided.

So, how did we coax Expression Engine into generating links for each article to it’s intended template group?

First step is to visit the CP Home › Admin › Weblog Administration › Weblog Management › Edit Weblog and choose Path Settings

Then, specify a “Weblog URL” or “Home” template for my weblog. You’ll see what I mean when you get there.

Having specified these paths for all of my weblogs, I can now ask EE to use them when generating links using this combination of path commands

{site_url}/{relative_url}/{url_title}

as illustrated below:

{exp:weblog:entries weblog="" .....}
<URL>
<
loc>{site_url}/{relative_url}/{url_title}</loc>
<
lastmod>{gmt_edit_date format='%Y-%m-%dT%H:%i:%s%Q'}</lastmod>
<
changefreq>daily</changefreq>
<
priority>0.5</priority>
</
URL>
{/exp:weblog:entries}

This then generated URL’s for each of my articles that included the Template Group I’d earlier specified in the weblog administration.

<URL>
<
loc>HTTP://www.divine-creations.com/projects/sole_to_soul_healing</loc>
<lastmod>2008-04-03T18:11:01+00:00</lastmod>
<
changefreq>daily</changefreq>
<
priority>0.5</priority>
</
URL>

<
URL>
<
loc>HTTP://www.divine-creations.com/blog/a_random_article</loc>
<lastmod>2008-04-03T18:11:01+00:00</lastmod>
<
changefreq>daily</changefreq>
<
priority>0.5</priority>
</
URL>

|

Feedback

If you'd like to respond to this article, please use the form provided below. Please note, all comments are moderated, so it might take a while for your remarks to be published.

Name:

Email:

Location:

URL:

Remember my personal information

Notify me of follow-up comments?

Submit the word you see below: