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.

Question for displaying blog entries

May 05, 2011 6:13am

Subscribe [3]
  • #1 / May 05, 2011 6:13am

    Scott Harrington

    85 posts

    Hi, not sure whether this can be done or not or whether its something simple that I’m overlooking. Using the code below, EE will display the three entries from within the specified blog in to the specified content, which is fine.

    <h2 class="feature">Lux De Ville</h2>
    <a href="#" title="more lux de ville">more lux de ville</a>
    {exp:channel:entries channel="lux-de-ville" limit="3"}
    <div class="itemcontainer">
    {site_url}assets/images/item-example.jpg
    <h3>{title}</h3>
    <p>{short-description}<br />
    {product-price}<br />
    </div><br />
    {/exp:channel:entries}

    However, Im having to hardcode the H2 and link for the range just above where I’m calling in the EE blog. The H2 is actually the title of the channel and the link through will point to the full list of entries, but I dont want them to duplicate along with the content thats within the class “itemcontainer”.

    So, what Im asking is, is there a way of calling it in as below, but only calling in the first two lines just the once and duplicating the the class just the three times as specified?

    {exp:channel:entries channel="lux-de-ville" limit="3"}
    <h2 class="feature">{channel}</h2>
    <a href="#" title="more lux de ville">more lux de ville</a>
    <div class="itemcontainer">
    {site_url}assets/images/item-example.jpg
    <h3>{title}</h3>
    <p>{short-description}<br />
    {product-price}<br />
    </div><br />
    {/exp:channel:entries}

    Hope this makes sense and thanks in advance for any info.

    Scott

    PS not sure if {channel} would display the channel name either

  • #2 / May 05, 2011 8:28am

    Mark Bowen

    12637 posts

    Hi Scott,

    Try this :

    {exp:channel:entries channel="lux-de-ville" limit="3"}
    
    {if count == "1"}
    <h2 class="feature">{channel}</h2>
    <a href="#" title="more lux de ville">more lux de ville</a>
    {/if}
    
    <div class="itemcontainer">
    {site_url}assets/images/item-example.jpg
    <h3>{title}</h3>
    <p>{short-description}<br />
    {product-price}<br />
    </div></p>
    
    <p>{/exp:channel:entries}

    {channel} is indeed a valid variable for the Channels tag.

    The {if} conditional will get your h2 and link just showing up the once. Not too sure what you meant by the class repeating the three times though but the div you have in there will output as many times as you have entries (in this case 3) so hopefully this should do what you’re after?

    Hope that helps a bit.

    Best wishes,

    Mark

  • #3 / May 05, 2011 11:19am

    Scott Harrington

    85 posts

    Spot on! Exactly what I wanted, thanks

  • #4 / May 05, 2011 11:24am

    Mark Bowen

    12637 posts

    Spot on! Exactly what I wanted, thanks

    Excellent news. Glad that got it sorted for you.

    Best wishes,

    Mark

  • #5 / May 05, 2011 6:30pm

    Brandon Jones

    5500 posts

    Thank you again, Mark! Glad that helped, Scott!

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

ExpressionEngine News!

#eecms, #events, #releases