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.

Hide "already shown" entry on exp:weblog:entries

March 11, 2008 12:48am

Subscribe [3]
  • #1 / Mar 11, 2008 12:48am

    mogya

    11 posts

    Hi all.

    On my site I want to show 1 random entry at first and another entries sorting by date.

    entry3 < random
    entry1 < by date
    entry2     :
    entry4
    entry5

    I wrote like this:

    {exp:weblog:entries weblog="myblog" orderby="random" limit="1"}
      //show 1 entry
    {/exp:weblog:entries}
    {exp:weblog:entries weblog="myblog" orderby="date"}
      //show another entries
    {/exp:weblog:entries}

    However in this way, 1 entry appeared 2 times(once by random,once by date).

    entry3 < random
    entry1
    entry2
    entry3 < second time!
    entry4
    entry5

    Q: Is there any way to hide this article at the second time?

    I tried to use Dynamically Assigned Variables but it didn’t work…

    {exp:weblog:entries weblog="myblog" orderby="random" limit="1"}
      //show 1 entry
      {assign_variable:shown_entry="{entry_id}"}//keep "shown" entry_id
    {/exp:weblog:entries}
    {exp:weblog:entries weblog="myblog" orderby="date" entry_id="not {shown_entry}"}
      //show another entries
    {/exp:weblog:entries}
  • #2 / Mar 31, 2008 2:53pm

    matt romaine

    50 posts

    hi mogya,

    have you tried turning on PHP processing? If you select PHP post-processing (on output) for the template, you could do something like:

    {exp:weblog:entries weblog="myblog" orderby="random" limit="1"}
        //show 1 entry
        <?php $shown_entry_id = {entry_id};?>  //keep "shown" entry_id
    {/exp:weblog:entries}
    {exp:weblog:entries weblog="myblog" orderby="date"}
        <?php if($shown_entry_id != {entry_id}):?>
            //show  entry
        <?php endif;?>
    {/exp:weblog:entries}

    I haven’t tested it, but with the correct settings the above should do what you’re looking for.

  • #3 / Apr 02, 2008 12:35am

    mogya

    11 posts

    Thanks! I got working with this code!

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

ExpressionEngine News!

#eecms, #events, #releases