Keyword

K2 Content Module - Time range not working as expected.

  • Tyler Ancell
  • Tyler Ancell's Avatar Topic Author
  • Offline
  • Junior Member
More
8 years 8 months ago - 8 years 8 months ago #150828 by Tyler Ancell
There's an article here describing how to do it with default joomla articles, there's only about 10 lines code:

Editing the module XML file and adding this:
<field name="nDays" type="text" default="0" label="N Days" description="Show the most read n last N days (0 is for all-time)">
    <option value="1">JSHOW</option>
    <option value="0">JHIDE</option>
</field>

Editing the module helper.php and adding this:
Add the following code-block:
//custom date condition
$nDays = $params->get('nDays');
if($nDays>0) {
    $model->setState('filter.nDays', $nDays);
}

Editing components/com_content/models/articles.php and adding this:
// Filter by Date Limit
if($this->getState('filter.nDays') && $this->getState('filter.nDays')>0) {
    $query->where("(TO_DAYS(NOW()) - TO_DAYS( a.created ) <= " . $this->getState('filter.nDays') . " )");
}

Is there any way to adapt this to K2? I don't mind changing the core files.

Thank you again!

Edit: If this ends up working in the way I hope it does, is it possible to add this to the K2 core? I love K2, and I would love for it to display trending items as I'm sure many others would.
Last edit: 8 years 8 months ago by Tyler Ancell.

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 8 months ago #150858 by Krikor Boghossian
Replied by Krikor Boghossian on topic K2 Content Module - Time range not working as expected.
That would not be possible since there is no information available on when the hit is being registered. The results shown would not be actually the most popular items.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • Tyler Ancell
  • Tyler Ancell's Avatar Topic Author
  • Offline
  • Junior Member
More
8 years 8 months ago - 8 years 8 months ago #150861 by Tyler Ancell
Last edit: 8 years 8 months ago by Tyler Ancell.

Please Log in or Create an account to join the conversation.

  • Tyler Ancell
  • Tyler Ancell's Avatar Topic Author
  • Offline
  • Junior Member
More
  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 8 months ago #150869 by Krikor Boghossian
Replied by Krikor Boghossian on topic K2 Content Module - Time range not working as expected.
Ask the developers of these extensions to double check if these extension truly offer the functionality you need.

In Joomla! (and K2 as well) only the hits are being stored and not when the hit was being made.

This means that you will still see the most popular articles that where created in the past x time. Not the most read within that time period.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum