- Posts: 23
COMMUNITY FORUM
- Forum
- K2 Community Forum
- English K2 Community
- K2 Content Module - Time range not working as expected.
K2 Content Module - Time range not working as expected.
- Tyler Ancell
-
Topic Author
- Offline
- Junior Member
Less
More
9 years 3 months ago - 9 years 3 months ago #150828
by Tyler Ancell
Replied by Tyler Ancell on topic K2 Content Module - Time range not working as expected.
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:
Editing the module helper.php and adding this:
Editing components/com_content/models/articles.php and adding this:
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.
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: 9 years 3 months ago by Tyler Ancell.
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- User
Less
More
9 years 3 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.
Please Log in or Create an account to join the conversation.
- Tyler Ancell
-
Topic Author
- Offline
- Junior Member
Less
More
- Posts: 23
9 years 3 months ago - 9 years 3 months ago #150861
by Tyler Ancell
Replied by Tyler Ancell on topic K2 Content Module - Time range not working as expected.
This is the site where I found the information:
www.deepesh.com.np/troubleshoot/most-popular-article-for-last-n-days-under-joomla-16.html
www.deepesh.com.np/troubleshoot/most-popular-article-for-last-n-days-under-joomla-16.html
Last edit: 9 years 3 months ago by Tyler Ancell.
Please Log in or Create an account to join the conversation.
- Tyler Ancell
-
Topic Author
- Offline
- Junior Member
Less
More
- Posts: 23
9 years 3 months ago #150863
by Tyler Ancell
Replied by Tyler Ancell on topic K2 Content Module - Time range not working as expected.
There's also this module:
extensions.joomla.org/extensions/extension/news-display/popular-content/most-popular-content-by-date-range
And this on stackexchange:
joomla.stackexchange.com/questions/4676/how-do-i-get-the-most-read-module-to-show-only-articles-within-a-time-range/4795#4795
I just don't know how to adapt it to K2.
extensions.joomla.org/extensions/extension/news-display/popular-content/most-popular-content-by-date-range
And this on stackexchange:
joomla.stackexchange.com/questions/4676/how-do-i-get-the-most-read-module-to-show-only-articles-within-a-time-range/4795#4795
I just don't know how to adapt it to K2.
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- User
Less
More
9 years 3 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.
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.
Please Log in or Create an account to join the conversation.
- Forum
- K2 Community Forum
- English K2 Community
- K2 Content Module - Time range not working as expected.