We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Blog Roll URL to individual entry

Development and Programming

NDC's avatar
NDC
22 posts
13 years ago
NDC's avatar NDC

Hey guys,

I am looking for how to link to the “pretty url” of a news entry. I have tried {permalink} and {page_url} both do not do what I want. Here is what my listing template looks like currently:

{exp:channel:entries channel="news|events" limit="10" dynamic="off" pagination="bottom" orderby="date"}

    <article>
  <header>
      <h2><a href="http://{page_url}" title="{title}">{title}</a></h2>
      <div class="post-meta">
       Posted on {entry_date}
      </div>
     </header>
 </article>  
 
{/exp:channel:entries}

I am wanting the place that has {page_url} to create a URL like this:

http://www.mysite.com/channel/My-Cool-Title

Thanks for your help.

Greg

       
Boyink!'s avatar
Boyink!
5,011 posts
13 years ago
Boyink!'s avatar Boyink!

There are a number of linking variables available in the channel://entries tag pair, I think you’re after either title_permalink or url_title_path which do exactly the same thing.

       
NDC's avatar
NDC
22 posts
13 years ago
NDC's avatar NDC

Thanks again for your help, but I am running into issues where i can’t dynamically change anything. For example, I have the listing template mentioned above and want to use that for 2 separate channels called news and events. So when I use just title_permalink it returns www.mysite.com/index.php/my-entry-title instead of www.mysite.com/index.php/channel/my-entry-title

I don’t want to have to have a separate template for every channel that I list, so how do I dynamically place the channel shortname within title_permalink=’channel/news’, for example I’ve tried the following:

<a href="{title_permalink='channel/{short_name}'" title="{title}">

Sorry for the confusion I just can’t seem to figure out dynamic variables within expression engine. Thanks again.

       
Boyink!'s avatar
Boyink!
5,011 posts
13 years ago
Boyink!'s avatar Boyink!

Well, lets back up a bit.

Do you have a grasp on what channels are for and what templates are for?

You don’t specify a channel name in a link. Channels just hold content, templates are how the content is pulled to a rendered page and so it’s template names that get specified in a link:

IE:

<a href="http://{url_title_path=template-group/template-name}">{title}</a>

You may happen to have both a channel and template group named ‘news’ - but that would just be a circumstance.

Now you are specifying multiple channels in your entries tag. If your need is to point the result link to a different template based on the channel it comes from you can do that, and the approach is covered here (see the 3 Weblogs, 1 Weblog:Entries Tag with Weblog-Specific Links - just mentally replace ‘weblog’ with ‘channel’ as the example was done in EE1 and EE2 uses channel instead)

http://www.train-ee.com/courseware/free-tutorials/comments/working-with-combined-weblogs

       
Boyink!'s avatar
Boyink!
5,011 posts
13 years ago
Boyink!'s avatar Boyink!
Well, lets back up a bit. Do you have a grasp on what channels are for and what templates are for? You don’t specify a channel name in a link. Channels just hold content, templates are how the content is pulled to a rendered page and so it’s template names that get specified in a link: IE:
<a href="http://{url_title_path=template-group/template-name}">{title}</a>
You may happen to have both a channel and template group named ‘news’ - but that would just be a circumstance. Now you are specifying multiple channels in your entries tag. If your need is to point the result link to a different template based on the channel it comes from you can do that, and the approach is covered here (see the 3 Weblogs, 1 Weblog:Entries Tag with Weblog-Specific Links - just mentally replace ‘weblog’ with ‘channel’ as the example was done in EE1 and EE2 uses channel instead) http://www.train-ee.com/courseware/free-tutorials/comments/working-with-combined-weblogs

If you are wanting one single entry template to display the result no matter what channel it comes from just make sure the channel:entries tag on that template also has both channels specified, and link to it using either the title permalink or url_title_path variable and it should work.

       
NDC's avatar
NDC
22 posts
13 years ago
NDC's avatar NDC
just make sure the channel:entries tag on that template also has both channels specified, and link to it using either the title permalink or url_title_path variable and it should work.

I have done this, but just for clarity here is my listing template I am using:

{exp:channel:entries channel="news|events" limit="10" dynamic="off" pagination="bottom" orderby="date"}

    <article>
  <header>
      <h2><a href="http://{title_permalink}" title="{title}">{title}</a></h2>
      <div class="post-meta">
       Posted on {entry_date}
      </div>
     </header>
 </article>  
 
{/exp:channel:entries}

But when I go to click the links they come back as:

http://testaqq.nana.com/index.php/christmas-party

Notice, the channel is missing.

       
Boyink!'s avatar
Boyink!
5,011 posts
13 years ago
Boyink!'s avatar Boyink!

Again, the channel does not need to be in the link. Link are made to templates, not channels. The linked-to template will know which entry to pull via the url_title that will have been added to the URL.

Have you read the docs for the title permalink variable?

       
NDC's avatar
NDC
22 posts
13 years ago
NDC's avatar NDC

Yes I did, I must be mis-understanding something. I’ll dig a little more and try to change some things around to get it to work. I’ll come back in a little bit if I’m still stumped.

       
Boyink!'s avatar
Boyink!
5,011 posts
13 years ago
Boyink!'s avatar Boyink!

Hint…Look for differences with your code vs. what the docs show..😉

       
NDC's avatar
NDC
22 posts
13 years ago
NDC's avatar NDC

I don’t think it’s the code becuase the code itself is executed as expected per the documentation. I think it may be the way that I am setting it up. I followed this tutorial for creating a blog (http://shapingthepage.com/journal/how-to-build-a-simple-tumblr-blog-with-expressionengine)

So my page has a conditional statement like so:

{if segment_1 == "news-events" AND segment_2 == ""}
          1
    {embed="blog/listing"}
   {if:elseif segment_1 == "news" AND segment_2 != ""}
    2
    {embed="blog/article"}
   {if:else}
    3
    {body} 
   {/if}

Am I going about this the wrong way, is there a better approach?

       
Boyink!'s avatar
Boyink!
5,011 posts
13 years ago
Boyink!'s avatar Boyink!

Personally I’d recommend starting simpler until you get a better feel for how EE works. Segments and conditionals and combined templates are a great next-step once you have the basics down. I’d start with separate templates for the listing and detail views before trying to combine them all.

You aren’t specifying a path with your title_permalink variable, so ee is just appending the url title of the entry onto the sites root domain. If you need other values in the segment_1 postion you need to specify them in the title_permalink variable.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.