ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

publishing entries and template url

October 29, 2011 5:13pm

Subscribe [3]
  • #1 / Oct 29, 2011 5:13pm

    auchumilk

    6 posts

    I have an article template that lists entries in the articles channel.

    {exp:channel:entries channel="article"}
         <h2><a href="http://{path=article/{url_title}}">{title}</a></h2>
    <p>     {excerpt}<br />
    {/exp:channel:entries}

    When I click on the link to read a full version of the article it redirects me back to the site index or homepage. I can’t seem to understand how to fix this issue. It should bring me to mysite.com/index.php/article/my_article_title, which shows the entry. I want to use only one template, the article template.

  • #2 / Oct 29, 2011 10:57pm

    mz91184

    100 posts

    It seems like you will want to use a conditional statement to utlize one template for the index and view page.  I didn’t check this code but here is my suggestion.

    {if segment_2}
      // full article
      {exp:channel:entries channel="article" url_title='{segment_2}'}
           <h2><a href="{path='article/{url_title}'}">{title}</a></h2>
    <p>       {excerpt}<br />
      {/exp:channel:entries}  <br />
     {if:else}<br />
      // index of articles<br />
      {exp:channel:entries channel="article"}<br />
           </p><h2><a href="{path='article/{url_title}'}">{title}</a></h2>
    <p>       {excerpt}<br />
      {/exp:channel:entries} <br />
     {/if}

  • #3 / Oct 30, 2011 8:25am

    ahmad saad

    364 posts

    I tested your code and it works well.

    if u can post all template code ,so I can help u.

  • #4 / Oct 30, 2011 2:26pm

    auchumilk

    6 posts

    This is article template, where I want a listing of articles and when someone clicks an article it reuses the template showing the entry. Can’t get it to work yet. When clicking the link, the url is correct. However, it displays the sites index page or homepage content instead of the entry.

    <body>
        <div class="container">
           <div class="span-15 prepend-1 colborder">
    
      {if segment_2 ==""}
         // index of articles
         {exp:channel:entries channel="article"}
             <h2><a href="http://{path=article/{url_title}}">{title}</a></h2>
    <p>           {excerpt}<br />
         {/exp:channel:entries} <br />
       {if segment_2 !=''}}<br />
         // full article<br />
         {exp:channel:entries channel="article" url_title='{segment_2}'}<br />
              </p><h2><a href="http://{path=article/{url_title}}">{title}</a></h2>
    <p>           {body}<br />
         {/exp:channel:entries}<br />
       {/if}   </p>
    
    
    
    <p> </div><br />
        </div><br />
      </body>

  • #5 / Oct 30, 2011 3:09pm

    auchumilk

    6 posts

    Not sure what I did, but it works properly now.

    <body>
        <div class="container">
           <div class="span-15 prepend-1 colborder">
    
      {if segment_2 ==""}
         // index of articles
        {exp:channel:entries channel="article"}
             <h2><a href="http://{path=article/{url_title}}">{title}</a></h2>
    <p>           {excerpt}<br />
         {/exp:channel:entries} <br />
      {/if}<br />
       {if segment_2 !=""}<br />
         // full article<br />
         {exp:channel:entries channel="article"}<br />
              </p><h2><a href="http://{path=article/{url_title}}">{title}</a></h2>
    <p>           {body}<br />
         {/exp:channel:entries}<br />
       {/if}</p>
    
    
    
    <p> </div><br />
        </div><br />
      </body>

  • #6 / Oct 30, 2011 4:05pm

    ahmad saad

    364 posts

    this is the problem:

    {if segment_2 !=''}}

    u put two }}.

  • #7 / Oct 31, 2011 4:44am

    John Henry Donovan

    12339 posts

    Glad you are up and running again. Feel free to start a new thread if you have any more questions.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases