0

I have a code which looks like this:

{exp:channel:entries channel="videos" search:category="some_category"}
<span>{some_field}<span>
<a href="www.domain.com/videos/{How to get url_title of this particular {some_field}?}"></a>
{/exp:channel:entries}

The problem is i cant go for another exp tag inside an exp tag.I want to redirect the user to a url that has url_title of the field(this title is being populated by a field from another channel).

I dont want to redirect the page to some other template.I just want to append a url title to www.something.com/videos/{append url title here...} .

1
  • You need to edit your question to state that you are working with a related entry and indicate how exactly you are relating it. i.e. In your videos channel, what fieldtype are you using to "attach" the other entry? How are you making the relationship? This is the critical bit of information you need to get a suitable answer. – foamcow May 19 '14 at 9:38
1

You would simply use {url_title} within your entries loop.

{exp:channel:entries channel="videos" search:category="some_category"}
<span>{title}<span>
<a href="www.domain.com/videos/{url_title}"></a>
{/exp:channel:entries}

In light of new information...

If the field is a relationship or Playa field you can access the URL title by using the field name as a tag pair and then your required tag within that. The precise method may vary depending on how you have things set up but try something like

{exp:channel:entries channel="videos" search:category="some_category"}
<span>{title}<span>
<a href="www.domain.com/videos/{mycustomfield}{url_title}{/mycustomfield}"></a>
{/exp:channel:entries}

This may not work due to namespacing and will return the url title for the parent entry, in which case you could try {mycustomfield:url_title}

Here are the docs for relationships in EE. Note that the way these work has changed in recent versions so if you are using an older version of EE you may need to do it slightly differently.

If all that fails then you could resort to using an embedded template but that's not particularly efficient.

3
  • you misunder stood the question..I want the url-title of the field..not the entry.That field is being populated from other channel.Hope i am clear – user2133 May 19 '14 at 8:07
  • No, your question wasn't clear. Is the field a relationship or using an add-on such as Playa? – foamcow May 19 '14 at 8:32
  • i have populated a field in my cahnnel video with a field that belongs to other channel.Now i want the url title of the field that is being populated.not the video entry itself.No playa used.No addon used – user2133 May 19 '14 at 8:43
0

Try using the title_permalink tag, for example:

{exp:channel:entries channel="videos" search:category="some_category"}
 <span>{title}<span>
 <a href="{title_permalink='videos'}"></a>
{/exp:channel:entries}

{title_permalink} - This variable uses the “url title” as the link. It defaults to the site index with the “url title”

In addition, you can specify a specific template group/template and the “url title” will automatically be added:

{title_permalink="template/location"}

see: http://ellislab.com/expressionengine/user-guide/add-ons/channel/channel_entries.html#title-permalink

Update

If you simply want to echo out the url title you should be able to use the variable:

{url_title}

"The human readable title used in the URL as a permalink."

http://ellislab.com/expressionengine/user-guide/add-ons/channel/channel_entries.html#id8

5
  • i dont want to redirect the page to some other template.I just want to append a url title to www.something.com/videos/{append url title here...} – user2133 May 19 '14 at 9:18
  • I've updated my answer – Alec Ritson May 19 '14 at 10:10
  • This isn't what the OP is asking. He is trying to output the url_title from a related entry. – foamcow May 19 '14 at 10:33
  • @foamcow : exactly.. – user2133 May 19 '14 at 11:03
  • In which case my amended answer details how you would do it. – foamcow May 19 '14 at 11:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy