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.

Single posts not working when {segment_3) contains the page url

November 20, 2012 10:31am

Subscribe [1]
  • #1 / Nov 20, 2012 10:31am

    verse

    26 posts

    Setting up a site that has three levels that consist of the following types of pages:

    Section page (/about/)
    Listing page (/about/blog)
    Detail page (/about/blog/blog-item-title)

    The Section and Listing pages work fine but the detail page wants to list all blog_items not just the one it should show, I’ve tried “dynamic=“yes” and this doesn’t work either.

    Here’s my code, shortened some unimportant parts (like comments form etc):

    {exp:switchee variable="{segment_2}" parse="inward"}
        
          {case value="#^P(\\\\d+)$#|''|category"}
            {embed="site/header" page_name="section"}
            {exp:channel:entries channel="{segment_1}" limit="1"}
              <h1>{title}</h1>
            {/exp:channel:entries}
          {/case}
          
    
          {case value="blog"}
            {if segment_3 == ""} <!-- Blog listing page -->
            
              {embed="site/header" page_name="listing"}
                <h1>Blog</h1>
                
                  {exp:channel:entries channel="blog_item" limit="10" paginate="bottom"}
              
                    <a href="http://{url_title_path=community/blog}">_                  <article>_                    <h1>{title}</h1>_                    {image:main wrap="image"}_                    {introduction}_                    <div class="body">_                      {body}_                    </div>_                  </article>_                </a>
              
                    {paginate}{/paginate}
              
                   {/exp:channel:entries}
            
            {if:else} <!-- Blog detail page -->
          
              {embed="site/header" page_name="detail"}
          
              {exp:channel:entries channel="blog_item" dynamic="yes"}
                  
                  <article>
                    <h1>{title}</h1>
                    {image:main wrap="image"}
                    {introduction}
                    <div class="body">
                      {body}
                    </div>
                  </article>
          
               {/exp:channel:entries}
               
               {exp:comment:form channel="blog_item" preview="channel/preview"}
               {/exp:comment:form}
                
               {exp:comment:entries sort="asc" limit="20"}
               {/exp:comment:entries}
              
              {/if}
            
            {/case}
        
      {/exp:switchee}
    
    {embed="site/footer"}
  • #2 / Nov 20, 2012 10:50am

    zizther

    228 posts

    Have you tried something like this for the single entry channel call:

    {exp:channel:entries channel="blog_item" url_title="{segment_3}" require_entry="yes"}

    You can swap url_title with entry_id depending on what you are using.

  • #3 / Nov 20, 2012 10:55am

    verse

    26 posts

    Thanks Zizther, {exp:channel:entries channel="blog_item" url_title="{segment_3}”} seems to work, however if I add “require_entry=“yes” then nothing is displayed, seems a little weird, any idea why?

    Thanks again!

  • #4 / Nov 20, 2012 11:11am

    zizther

    228 posts

    The ‘require_entry’ parameter is used in conjunction with the if no_results conditional.
    It is not required for the site to work though

    Not sure why it wouldn’t be working with it in though.

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

ExpressionEngine News!

#eecms, #events, #releases