related entries : path of the entries
Posted: 05 January 2008 08:05 AM   [ Ignore ]
Newbie
Rank
Total Posts:  15
Joined  2007-08-07

Hello,
I have a few templates on my site.
One template is “loger”. I display here entries from a particular category. Below the entry, I display the tag related_entries. Here, related entries belongs to other categories, and other templates.
If I code url_title_path like above, I’m not able to display the entries who belongs not to “loger”.

{exp:tag:related_entries  limit="10" }
<li><a href="{url_title_path=site/loger/}">{title}</a></li>
{/exp:tag:related_entries}

Is it possible to get the correct path of an entry ? How code this ?

Profile
 
 
Posted: 05 January 2008 09:53 AM   [ Ignore ]   [ # 1 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  3272
Joined  2006-10-18

If I understand you correctly, you would like a way to have the URL Path know which template you’d like the entry to be displayed on in the link generated?

There is currently no real “easy” way due to the nature of it. But there are a couple workarounds…

You can do this basing off of Weblog structure, Category structure, or Custom Fields.

Weblog Structure:

For example, you could create the template group in your to match the Weblog an entry belongs to with the {weblog_url} variable. So, if an entry was to belong to Weblog “Weblog B” and the URL Title for the Weblog (which is changable) is say “template_group_b”.... create your Template Group you’re linking to to match that URL Title.

<div class="title"><a href="/{weblog_url}/comments/{entry_id}/">{title}</a></div>

When the entries populate, the {weblog_url} variable will fill in with the cooresponding template name it was designated… example:

<a href="template_group_a/comments/1"}">Title of entry 1 from Weblog A</a>
<a href="
template_group_b/comments/2"}">Title of entry 2 from Weblog B</a>
<
a href="template_group_c/comments/3"}">Title of entry 3 from Weblog C</a>
<a href="
template_group_a/comments/4"}">Title of entry 4 from Weblog A</a>
<
a href="template_group_c/comments/5"}">Title of entry 5 from Weblog C</a>

Category Structure:

For example, you could create the template group in your to match the Category an entry belongs to with the {category_url_title} variable. So, if an entry was to belong to category “Category B” and the URL Title for the category (which is changable) is say “template_group_b”.... create your Template Group you’re linking to to match that URL Title.

<div class="title">{categories show="1|2|4|5|7|9|"}<a href="/{category_url_title}/comments/{entry_id}/">{title}</a>{/categories}</div>

In that example, use the show="” parameter only if your entries belong to multiple categories… primarily, in the case of Sub Categories. What will happen is you’ll get the results for BOTH categories in the URL Title. The show="” parameter would weed out say Primary Categories or Secondary Categories, of which ever you select. In the case that you have entries that belong to multiple Categories that you need both/all listed, you’re out of luck. Use Custom Fields.

When the entries populate, the {category_url_title} variable will fill in with the cooresponding template name it was designated… example:

<a href="template_group_a/comments/1"}">Title of entry 1 from Category A</a>
<a href="
template_group_b/comments/2"}">Title of entry 2 from Category B</a>
<
a href="template_group_c/comments/3"}">Title of entry 3 from Category C</a>
<a href="
template_group_a/comments/4"}">Title of entry 4 from Category A</a>
<
a href="template_group_c/comments/5"}">Title of entry 5 from Category C</a>

Custom Fields:

First, you create a custom field as you normally would, but make it a dropdown menu, with the cooresponding template Names…
ex: template1, template2, template3, etc
Every time you or an author creates a new entry, have them select the cooresponding template name from that dropmenu. That data is then posted…

We’re going to say you call that custom field “template_name”, and that you’re using Template Groups for each different templated entry. We’re also going to assume in the example that you’re using a Template called “comments” for each Template Group to display the entries. (You could also do this roughly the same way if you want to use the SAME Template Group for all entries, but a different Template.... just switch a couple things around).

Now, when you generate your links for the related entries, you can make your related entries code look exactly as this:

<a href="{permalink="{template_name}/comments"}">{title}</a>

When the entries populate, that custom field will fill in with the cooresponding template name it was designated… example:

<a href="template1/comments/1"}">Title of entry 1</a>
<a href="
template1/comments/2"}">Title of entry 2</a>
<
a href="template3/comments/3"}">Title of entry 3</a>
<a href="
template2/comments/4"}">Title of entry 4</a>
<
a href="template1/comments/5"}">Title of entry 5</a>

Of course, you want to make sure that the Templating Structure matches those template names, in this case, that’s the location of the Template Group, so you’d want to make sure “template1”, “template2”, and “template3” would exist as template group names, and that the “comments” templates would exist within those groups.

Now of course, all the names I used were only examples, you can name anything whatever you like.

 Signature 
Profile
 
 
Posted: 12 January 2008 03:52 AM   [ Ignore ]   [ # 2 ]
Newbie
Rank
Total Posts:  15
Joined  2007-08-07

Thanks for the reply.
I try here the custom field solution.

<ul>
{exp:tag:related_entries limit="10" }
<li><a href="{url_title_path=´site/{template_name}/´}">{title}</a></li>
{/exp:tag:related_entries}
</ul>

url don’t work : I don’t get any value in {template_name}.

Url is like this : http://.../index.php/site/decouvrir/{url_title_path=´site//´}

If I surround the code with {exp:weblog:entries ...} (same params as the {exp:weblog:entries ...} who give me the entry of the page, see below,
I get the correct URL ({template_name} is filled with the correct value), but {title} is filled with the page main article title, not the title(s) of the related articles.

{exp:weblog:entries weblog="web" orderby="date" sort="desc" limit="1" category="4" status="Fixe|open"}
<ul>
{exp:tag:related_entries limit="10" }
<li><a href="{url_title_path=´site/{template_name}/´}">{title}</a></li>
{/exp:tag:related_entries}
</ul>
{/exp:weblog:entries}

Where i’m wrong ?

Profile
 
 
Posted: 12 January 2008 08:35 AM   [ Ignore ]   [ # 3 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  3272
Joined  2006-10-18

EDIT: See post below....

 Signature 
Profile
 
 
Posted: 12 January 2008 09:16 AM   [ Ignore ]   [ # 4 ]
Newbie
Rank
Total Posts:  15
Joined  2007-08-07

:-(( No the only method was custom fields.

And with a query ? Is entry_id available at this time ?

Profile
 
 
Posted: 13 January 2008 07:21 AM   [ Ignore ]   [ # 5 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  3272
Joined  2006-10-18

Custom fields do work, but…

The problem seems to be using a custom field variable in the url_title or permalink paths.

I will classify this as a Tag bug. smile

I apologize for the inconvenience.

 Signature 
Profile
 
 
Posted: 13 January 2008 05:20 PM   [ Ignore ]   [ # 6 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  701
Joined  2004-03-30

jpol,

In testing and trying to reproduce in order to fix this bug, I am finding something worth mentioning.

I can reproduce everything you guys have mentioned above. However, it should be pointed out that in my testing the weblog:entries module, when used with the url_title_path approach, yields the same results as the tag:related_entries function. In neither case will the presence of that custom weblog variable allow the url_title_path variable to parse properly. This makes sense as the tag:related_entries function merely passes over to the weblog:entries function a list of entries to show. All of the variable parsing and formatting from that point on behaves exactly as the weblog:entries function does.

I’ll try and talk PieMan out of recording this as a Tag module bug now.

mk

 Signature 

Mitchell Kimbrough

Profile
 
 
Posted: 13 January 2008 11:40 PM   [ Ignore ]   [ # 7 ]
Newbie
Rank
Total Posts:  15
Joined  2007-08-07
Mitchell Kimbrough - 13 January 2008 05:20 PM

jpol,

I’ll try and talk PieMan out of recording this as a Tag module bug now.

mk

Mitchel, tanks for the help.
Excuse my bad english. I don’t understand very well what you mean here.
Do you mean it’s a bug ? Is it possible to get a solution for this problem ? It’s a solspace bug, or a EE bug ?

I know it’s possible to parse custom fields in the loop (sometimes I display {titre_fr}, not {title})
Is it possible to do a query to work around ?

Profile
 
 
Posted: 14 January 2008 12:17 AM   [ Ignore ]   [ # 8 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  701
Joined  2004-03-30

From what I can tell, the weblog:entries tag does not correctly parse {url_title_path=’’} when a custom field variable is placed inside it. Since the Tag module relies on the weblog:entries tag for this parsing, it is a bug in EE.

mk

 Signature 

Mitchell Kimbrough

Profile
 
 
Posted: 14 January 2008 08:13 AM   [ Ignore ]   [ # 9 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  3272
Joined  2006-10-18

You’re right Mitchell… Thank you smile

I thought I had done it before (custom fields with permalink path), but come to think of it now… I remember that did not work, and I ended up just hardcoding part of the path with the custom_field, and the entry_id variables (or in your case jpol, the url_title variable).

So, as a workaround, this should work:

<ul>
{exp:tag:related_entries limit="10" }
<li><a href="/site/{template_name}/{url_title}/">{title}</a></li>
{/exp:tag:related_entries}
</ul>

Or (if you use the index.php in your URL):

<ul>
{exp:tag:related_entries limit="10" }
<li><a href="/index.php/site/{template_name}/{url_title}/">{title}</a></li>
{/exp:tag:related_entries}
</ul>

 Signature 
Profile
 
 
Posted: 23 January 2008 04:59 AM   [ Ignore ]   [ # 10 ]
Newbie
Rank
Total Posts:  15
Joined  2007-08-07

Pie Man,

I try the last code with success !

Thanks !

Profile
 
 
Posted: 23 January 2008 07:14 AM   [ Ignore ]   [ # 11 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  3272
Joined  2006-10-18

Good to hear! smile

 Signature 
Profile