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.

How to: Homepage featured articles rotate on page refresh.

July 09, 2012 9:47pm

Subscribe [3]
  • #1 / Jul 09, 2012 9:47pm

    bmpire

    27 posts

    Hello,

    I am trying to figure out how to accomplish the following:

    1.)  Display random articles in the featured articles section on the homepage that would pull articles from a specific channel(s).

    I would like these featured articles to change either with each page refresh or just change daily(24 hours). 

    What could I use to accomplish this?  Is this something that comes standard anywhere in EE?

    We would also like the above to accomplish a random fact of the day area.  The fact or links would change daily.

    Thanks for your help. Its MUCH appreciated.

    Brandon

  • #2 / Jul 10, 2012 4:25am

    Ian Ebden

    312 posts

    For the random articles section just use the orderby=“random” channel parameter.

    {exp:channel:entries channel="my_channel" dynamic="no" limit="3" orderby="random"}<h1>{title}</h1>{/exp:channel:entries}

    If you want to display a random entry for 24 hrs I think you could add in the cache/refresh params too. That might do it. e.g.

    {exp:channel:entries cache="yes" channel="my_channel" dynamic="no" limit="1" orderby="random" refresh="1440"}<h1>{title}</h1>{/exp:channel:entries}

    Hope that helps.

  • #3 / Jul 10, 2012 6:39pm

    bmpire

    27 posts

    Ian,

    Thanks so much for the feedback!  I will definitely gives those a try.

    Also,

    Is it possible to have certain articles show up for a specific date?  Say if we wanted to have an article for christmas and it would only be displayed on December 25th? 

    How would we accomplish this?

    Thanks again!

    Brandon

  • #4 / Jul 11, 2012 4:05am

    Ian Ebden

    312 posts

    Hi Brandon – Not tried that before but you could probably achieve it using the start_on and stop_before params. First, you’d create your Christmas entry and set the Start Date to 2012-12-25 00:00. Then add this to your template:

    {exp:channel:entries
     channel="my_channel"
     dynamic="no"
     limit="1"
     start_on="2012-12-25 00:00"
     stop_before="2012-12-25 23:59"
    }
    {title}
    {/exp:channel:entries}

    That might do it.

  • #5 / Jul 11, 2012 11:19am

    Shane Eckert

    7174 posts

    Hey BMPIRE,

    I am glad to see that Ian was able to provide so much assistance here! Thanks Ian.

    Sounds like you have what you need.

    Is there anything else I can help with?

    Cheers,

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

ExpressionEngine News!

#eecms, #events, #releases