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.

conditional variable for latest entry time?

June 27, 2007 6:07am

Subscribe [1]
  • #1 / Jun 27, 2007 6:07am

    superaven

    107 posts

    hello all…

    i’m stuck trying to create a conditional variable based on latest entry. for example:

    {if latest_entry =< "24 hours"}
    
    display new content
    
    {/if}

    i know the code above isn’t supposed to work, but it illustrates what i’m trying to accomplish. anyone have any quick tips on how i can pull this off?

    thanks in advance.

  • #2 / Jun 27, 2007 9:21am

    silenz

    1651 posts

    If you enable PHP on Input stage for the template a quick way might be something along the line of:

    <?php
    $offset = date ("Y-m-d H:i",mktime()-86400);
    ?>
    
    {exp:weblog:entries orderby="date" sort="desc" start_on="<?php echo $offset;?>"}
    
    <h4>{title}</h4>
    
    <p>{/exp:weblog:entries}

    where 86400 is 24*60*60 seconds or 24 hours.

  • #3 / Jun 27, 2007 12:46pm

    superaven

    107 posts

    silenz,

    thanks for you reply… actually though that helps me with something i’m still getting to, it doesn’t solve my current problem. (i should have explained myself a little more). what i’m attempting to do is have a ‘new’ graphic show up next to blogs that have had a new entry added within the last 24 hours. the ‘new’ graphic itself will be displayed via css. i figured maybe EE had a variable i dont know about to pull the latest_entry_date data out of the exp_weblogs table, so i could use a conditional statement to include the appropriate css for either instance (new or old). apparently it doesn’t seem to, so i tried using the query module to pull the data out. now i’m not sure how to use an EE variable within a php statement to create the statement.

    
    									
  • #4 / Jun 28, 2007 6:36am

    silenz

    1651 posts

    Probably even simpler would be to just pull the latest entry from a weblog and see if it has been posted within 24 hours.

    <?php $offset = mktime()-86400; ?>
    
    {exp:weblog:entries weblog="my_weblog" orderby="date" sort="desc" limit="1"}
    {if entry_date > <?php echo $offset; ?>}
    
       last entry ({title}) is newer than 24 hours 
    
    {/if}
    {/exp:weblog:entries}

    You might have to to adjust the 86400 to reflect your adjusted GMT.

  • #5 / Jun 28, 2007 7:38am

    superaven

    107 posts

    silenz,

    thanks for the tip. with a lot of help from a friend (who’s far more proficcient with php then i), i managed to get the code to do what i wanted. in this caser, it’s a 4 row, by 4 column grid of squares, each representing a blog. here’s is the code i used to accomplish it…

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

ExpressionEngine News!

#eecms, #events, #releases