2

Okay, I've got a page with a url that has the channel entry title in the URL. At the beginning of the page, I show the single article for that entry, but then underneath the article, I need to show all the other articles. So I can do this by setting dynamic="no" which reverts it to a normal channel:entries loop, but I would like this loop to skip and ignore the entry that is showing ta the top of the page.

I do not know how other to do this, but I put a if statement in my channel entries loop, but the problem is, I'm using switch to setup div's for a new row every third entry and the if statement messes with that.

I need the channel entries to ignore a particular entry, or I need a way to do a "continue" for the loop without messing with the switch count.

Here's my current code:

{if last_segment}
    {exp:channel:entries channel="event" orderby="date" sort="desc" status="open" category="10" dynamic="no" limit="7"}
        {if url_title != last_segment}
{switch="<div class='eventsRow'>||"}
    <div id="{url_title}" class="event {switch="|| lastEvent"}" data-count="{count}">
        <div class="pastEventConent">
            <h4>{title}</h4>
            <p>{excerpt}</p>
            <div class="copy">
                {copybox1}
            </div>
            <a data-tag="{url_title}" href="{title_permalink='events'}">View >></a>
        </div>
    </div>
{switch="||</div>"}
        {/if}
    {/exp:channel:entries}
{if:else}
    {exp:channel:entries channel="event" orderby="date" sort="desc" status="open" category="10" offset="1" dynamic="no" limit="6"}
{switch="<div class='eventsRow'>||"}
    <div id="{url_title}" class="event {switch="|| lastEvent"}" data-count="{count}">
        <div class="pastEventConent">
            <h4>{title}</h4>
            <p>{excerpt}</p>
            <div class="copy">
                {copybox1}
            </div>
            <a data-tag="{url_title}" href="{title_permalink='events'}">View >></a>
        </div>
    </div>
{switch="||</div>"}
    {/exp:channel:entries}
{/if}

Any help appreciated :)

7

Much simpler than you think! Just add url_title="not '{segment_3}'" to your Channel Entries tag. (Or whichever segment holds your entry's url_title.)

| improve this answer | |
  • I love you!!!!! – Garthm Jan 16 '13 at 11:18
  • The other issue (the conditional messing with number of items that insert div with switch='' variable), styling can also be done on the CSS side of things with help of nth-child selector. w3schools.com/cssref/sel_nth-child.asp – GDmac Jan 16 '13 at 14:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.