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.

displaying a single article

January 25, 2011 7:17am

Subscribe [4]
  • #1 / Jan 25, 2011 7:17am

    Hey,

    I am trying to display a single article from a list of entries when the link is clicked on by the user.

    Everything from my template is pulled in through the link except my content, help?  :grrr:

    Here is the code I am using:

    {if segment_1=="blog"}
    {exp:channel:entries channel="blog" dynamic="off" orderby="date" disable="member_data|pagination|trackbacks|categories|category_fields"}
    <a href="http://{path="><h2>{default_heading}</h2><p></a><br />
    <a href="http://{path=">{if default_image}{default_image}</a>{/if}<br />
    {if default_content}{default_content}{/if}<br />
    <div class="border"></div><br />
    {/exp:channel:entries}<br />
    {/if}

  • #2 / Jan 25, 2011 7:35am

    KeithW

    138 posts

    You can find a description of parameters such as “limit” here. Have you tried omitting “dynamic” (default is “yes”)?

  • #3 / Jan 25, 2011 7:39am

    Not really,

    Basically, the page shows all the recent blog entries but I want to be able to view that single article by clicking on the blog heading, if that makes sense?

  • #4 / Jan 25, 2011 7:48am

    KeithW

    138 posts

    Are you thinking of something like this? This is EE1.7, but the principle should be the same.

  • #5 / Jan 25, 2011 7:59am

    Yes this is the kind of thing I am after, I am fairly new to EE and I have been pulling my hair out the last few days!  :down:

  • #6 / Jan 25, 2011 10:39am

    KeithW

    138 posts

    I think the key issue is that the template for the “master index of items” (with multi-item “limit”, and “pagination”)
    and the template for the “detail” of each item (with single-item “limit”) are different, so clicking a “master index”
    link in the “/archive/” takes you to “detail” in “/past/”.  Is that enough for you to solve the problem? 
    Not sure if you need to remove your “dynamic” parameter (default, if omitted, seems to be “yes”), but maybe so.

  • #7 / Jan 25, 2011 11:19am

    These pages run on the same template.

    I have one index template with a few {if} conditions and embeds templates to cover different elements of my webpage so I am still unsure why it wont pull through the content :sick:

  • #8 / Jan 25, 2011 12:16pm

    KeithW

    138 posts

    Why not get it working (displaying both title and body) by omitting conditionals, then add
    “click on title link to display just one article” functionality and get that working, and so on.

    You have to decide how many items to display in a template—for a master index you display several,
    but for a detail display you display just one.  So why not get this working using separate templates
    (i.e. different URLs) for master and detail, and then (if you must, though I can’t understand why you’d
    want to) try to add logic so that either master or detail can be displayed on a single template.

  • #9 / Jan 26, 2011 3:43am

    John Henry Donovan

    12339 posts

    baseline-creative,

    By way of learnign I have simplified a set-up in the gist of what you require

    In your blog/index template add this

    {exp:channel:entries channel="blog" orderby="date" disable="member_data|pagination|categories|category_fields"}
    <a href="http://{comment_url_title_auto_path}"><h2>{default_heading}</h2><p></a><br />
    <a href="http://{comment_url_title_auto_path}">{if default_image}{default_image}</a>{/if}<br />
    {if default_content}{default_content}{/if}<br />
    <div class="border"></div><br />
    {/exp:channel:entries}

    Then in a blog/more template add this

    {exp:channel:entries channel="blog"  disable="member_data|pagination|categories|category_fields" limit="1" url_title="{segment_3}"}
    <h2>{default_heading}</h2>
    <p>{if default_image}{default_image}{/if}<br />
    {if default_content}{default_content}{/if}<br />
    <div class="border"></div><br />
    {/exp:channel:entries}

    In your channel preferences update the Comment Page URL to http://www.mydomain.com/index.php/blog/more

    This will populate the {comment_url_title_auto_path} correctly

    I also removed trackbacks from your disable parameter as that module does not exist in EE2.

    Let us know if that helps

  • #10 / Jan 26, 2011 10:34am

    Thanks very much John, this has completely resolved my issue!

    😊

  • #11 / Jan 26, 2011 3:17pm

    Ingmar

    29245 posts

    Excellent. Please post again as needed.

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

ExpressionEngine News!

#eecms, #events, #releases