Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • arucardx Friend
    #179560

    As we all know, the new button was only meant for Demo purpose in the JA Wall demo. But the CSS button style is still included in the JA Wall package, just that there is no place to configure to get it to work alongside the Hot button. Perhaps like me, you have attempted to hire a freelancer to automate the process, but it ended with no result. Strangely, with no php knowledge, I was able to figure it out myself, and so to save future troubles, I decided to share it and hopefully to get more ppl to share their modification.

    So in here, I will explain how you can get the New Button to automate and get it to work like the Hot Button. I will break this article into two section. One for Joomla and One for K2.

    Step 1: Locate the php file to modify.
    K2 : Open category_item.php in templateja_wallhtmlcom_k2ja_wall
    Joomla: Open blog_item.php in templateja_wallhtmlcom_contentcategory

    Step 2: Define the variables.
    For K2 – Search for
    [PHP]$hothits = (int) $tmpl->params->get (‘hothits’, 1000);[/PHP]
    For Joomla – Search for
    [PHP]$hothits = $tmpl->params->get (‘hothits’, 1000);[/PHP]

    Now below that line, press enter once or twice to make some free space and enter this code.
    [PHP]$newdate = strtotime($this->item->publish_up) + 259200;
    $nowdate = time();[/PHP]

    $newdate will attempt to take the published date of the article and add 259200 seconds to the date, which translate to 72 hours. You can adjust the duration if you like. If you want to use the creation date instead, just change “publish_up” to “created” so it looks like [PHP]$this->item->created[/PHP]

    $nowdate will take the current server time for reference later.

    Step 3: Now to get the new button to display.
    K2 & Joomla – Search for
    [PHP]<?php echo $this->item->hits >= $hothits?’ item-hot’:” ?>[/PHP]

    Now before that code, don’t press enter here. Add in this.
    [PHP]<?php echo $nowdate <= $newdate?’ item-new’:” ?>[/PHP]
    Make sure you enter this within the div item class. Just for confirmation purpose, it should look like this.
    K2 –
    <div class="item <?php echo $xclass ?><?php if(empty($this->item->image)) echo " no-image";?><?php echo $nowdate <= $newdate?' item-new':'' ?><?php echo $this->item->hits >= $hothits?' item-hot':'' ?>">
    Joomla –
    <div class="item<?php echo $this->item->state == 0 ? ' system-unpublished' : null; ?> <?php echo $xclass ?><?php echo $this->item->hits >= $hothits?' item-hot':'' ?> <?php echo strtolower($this->item->category_alias); ?> <?php if(empty($images->image_intro)) echo "no-image";?>">

    What that line of code does is compared the if current server time $nowdate is within the 3 days period from the publication date. If yes, it will then echo item-new which acts as a css class. If no, then it will continue to check if hot button should echo.

    Note: Only 1 button can appear at any one time btw. So you can’t have Hot & New button appearing together, I’m not sure why.. but I think the problem lies with the CSS in template.css. If you want Hot button to take precedence over New button then just switch the order of the two code so it’ll print item-hot ahead of item-new. You get the idea =D

    If this helps you, please thank the post and also share your modification in JA Wall Guides so fellow wall builders can help one another and make this an even better template!

    John Wesley Brett Moderator
    #462876

    A brilliant modification! Thank you so much for contributing and welcome!

    John

    mbs2008 Friend
    #484326

    This worked great! Thanks for the info.

    However, maybe the code was tweaked a bit due to the latest JA Wall update, so my code for step #3 looked like this:

    if($nowdate <= $newdate){ $iclass[] = ‘item-new’; }

    Placing it before the “item hot” code:

    $iclass = array(‘item’, JApplication::stringURLSafe($this->item->categoryname));
    if(!empty($xclass)){ $iclass[] = $xclass; }
    if(empty($this->item->image)){ $iclass[] = ‘no-image’; }
    if($nowdate <= $newdate){ $iclass[] = ‘item-new’; }
    if($this->item->hits >= $hothits){ $iclass[] = ‘item-hot’; }

    lvogeltanz Friend
    #486539

    Hi, I would like use this very good idea. I try this help and not function for me :-(. I have last version 1.08. I think I do mistake in STEP 3 🙁 I dont know where can I put this code… 🙁 Can you help me?

Viewing 4 posts - 1 through 4 (of 4 total)

This topic contains 4 replies, has 4 voices, and was last updated by  lvogeltanz 11 years, 7 months ago.

We moved to new unified forum. Please post all new support queries in our New Forum