Results 1 to 10 of 10

Thread: Set time frame in sidebar_stories_u.php to number of days

  1. #1
    Pligg Donor ditto's Avatar
    Joined
    Dec 2007
    Posts
    40

    Set time frame in sidebar_stories_u.php to number of days

    I have searched the forum for an answer, but i did not find it...

    In sidebar_stories_u.php i can modify the time frame for the top stories in the sidebar, my options seem to only be today, yesterday, week, month and year.

    This is problematic for me, because i use "month", and every new "month" i get a couple of days with no content in my sidebar for "Top this month".

    What would be really great, would be to be able to set a number of days as a time frame in sidebar_stories_u.php, in my case 30 days.

    Is it possible? Can somebody point me in the right direction?

  2. #2
    Constant Pligger xiesi's Avatar
    Joined
    Jun 2007
    Posts
    223
    I set it to week.

  3. #3
    Pligg Donor abraxas's Avatar
    Joined
    Feb 2008
    Posts
    97
    I'm looking for how to do this as well. Any ideas?

  4. #4
    Pligg Donor abraxas's Avatar
    Joined
    Feb 2008
    Posts
    97
    I know so far that the action lies within the templates/.../index_center.tpl, but I don't know yet what setmeka is or how the if/else statements work with this.
    Any ideas from anyone?
    It would really make sense to have it set to 7days and 30days, as far as I can see.

  5. #5
    Pligg Donor abraxas's Avatar
    Joined
    Feb 2008
    Posts
    97

    **bump**

    Does anyone have an idea about this?

  6. #6
    Constant Pligger xiesi's Avatar
    Joined
    Jun 2007
    Posts
    223
    I don't know how to do.
    i use "week"

  7. #7
    Pligg Donor longcountdown's Avatar
    Joined
    Nov 2007
    Posts
    75

    Set time frame to 30 days

    I'm looking for an "X days" solution to this, too.

    Update: I found a fix myself (at least for 9.8.2). Here it is:

    1. Open libs/search.php and find:

    Code:
    if ($this->filterToTimeFrame == 'today') {
    			$tsdt = date('Ymd000000', strtotime("now"));
    			$fsdt = date('Ymd235959', strtotime("now"));
    			$from_where .= " AND (link_published_date >= $tsdt AND link_published_date <= $fsdt) ";
    		}
    2. Copy and paste that just above itself, so now you have:

    Code:
    if ($this->filterToTimeFrame == 'today') {
    			$tsdt = date('Ymd000000', strtotime("now"));
    			$fsdt = date('Ymd235959', strtotime("now"));
    			$from_where .= " AND (link_published_date >= $tsdt AND link_published_date <= $fsdt) ";
    		} 
    
    if ($this->filterToTimeFrame == 'today') {
    			$tsdt = date('Ymd000000', strtotime("now"));
    			$fsdt = date('Ymd235959', strtotime("now"));
    			$from_where .= " AND (link_published_date >= $tsdt AND link_published_date <= $fsdt) ";
    		}
    3. Edit the top one for your desired time frame (my changes in red), then upload the file:

    Code:
    if ($this->filterToTimeFrame == 'last30days') {
    			$tsdt = date('Ymd000000', strtotime("-30 days"));
    			$fsdt = date('Ymd235959', strtotime("now"));
    			$from_where .= " AND (link_published_date >= $tsdt AND link_published_date <= $fsdt) ";
    		}
    Note: I've used -30 days, but check W3Schools for variations on the format.

    4. Find /sidebar_stories_u.php and change:

    Code:
    else {	
    		$ss->filterToTimeFrame = 'today'; // filter the past 24 hours	
    		$ss->header = $main_smarty->get_config_vars("PLIGG_Visual_Top_Today");
    	}
    to:

    Code:
    else {	
    		$ss->filterToTimeFrame = 'last30days'; // filter the last 30 days	
    		$ss->header = $main_smarty->get_config_vars("PLIGG_Visual_Recently_Pop");
    	}
    5. Upload that, then repeat the whole process for different time frames.

    Hope that helps you guys!

  8. #8
    Pligg Donor abraxas's Avatar
    Joined
    Feb 2008
    Posts
    97
    Thanks for the solution on this.
    I'm trying to work it out for week and month.
    Does the part for sidebar_stories_u repeat for week and month?

    else {
    $ss->filterToTimeFrame = 'today'; // filter the past 24 hours
    $ss->header = $main_smarty->get_config_vars("PLIGG_Visual_Top_Today");
    }

    -7 days and again for -30 days

    Thank you.


    Quote Originally Posted by longcountdown View Post
    I'm looking for an "X days" solution to this, too.

    Update: I found a fix myself (at least for 9.8.2). Here it is:

    1. Open libs/search.php and find:

    Code:
    if ($this->filterToTimeFrame == 'today') {
    			$tsdt = date('Ymd000000', strtotime("now"));
    			$fsdt = date('Ymd235959', strtotime("now"));
    			$from_where .= " AND (link_published_date >= $tsdt AND link_published_date <= $fsdt) ";
    		}
    2. Copy and paste that just above itself, so now you have:

    Code:
    if ($this->filterToTimeFrame == 'today') {
    			$tsdt = date('Ymd000000', strtotime("now"));
    			$fsdt = date('Ymd235959', strtotime("now"));
    			$from_where .= " AND (link_published_date >= $tsdt AND link_published_date <= $fsdt) ";
    		} 
    
    if ($this->filterToTimeFrame == 'today') {
    			$tsdt = date('Ymd000000', strtotime("now"));
    			$fsdt = date('Ymd235959', strtotime("now"));
    			$from_where .= " AND (link_published_date >= $tsdt AND link_published_date <= $fsdt) ";
    		}
    3. Edit the top one for your desired time frame (my changes in red), then upload the file:

    Code:
    if ($this->filterToTimeFrame == 'last30days') {
    			$tsdt = date('Ymd000000', strtotime("-30 days"));
    			$fsdt = date('Ymd235959', strtotime("now"));
    			$from_where .= " AND (link_published_date >= $tsdt AND link_published_date <= $fsdt) ";
    		}
    Note: I've used -30 days, but check W3Schools for variations on the format.

    4. Find /sidebar_stories_u.php and change:

    Code:
    else {	
    		$ss->filterToTimeFrame = 'today'; // filter the past 24 hours	
    		$ss->header = $main_smarty->get_config_vars("PLIGG_Visual_Top_Today");
    	}
    to:

    Code:
    else {	
    		$ss->filterToTimeFrame = 'last30days'; // filter the last 30 days	
    		$ss->header = $main_smarty->get_config_vars("PLIGG_Visual_Recently_Pop");
    	}
    5. Upload that, then repeat the whole process for different time frames.

    Hope that helps you guys!

  9. #9
    Pligg Donor longcountdown's Avatar
    Joined
    Nov 2007
    Posts
    75
    "Does the part for sidebar_stories_u repeat for week and month? "

    No, you only need it once. Let's imagine you've added two time frame filters (7 days and 30 days) to libs/search.php:

    Code:
    if ($this->filterToTimeFrame == 'last7days') {
    			$tsdt = date('Ymd000000', strtotime("-7 days"));
    			$fsdt = date('Ymd235959', strtotime("now"));
    			$from_where .= " AND (link_published_date >= $tsdt AND link_published_date <= $fsdt) ";
    		}
    
    if ($this->filterToTimeFrame == 'last30days') {
    			$tsdt = date('Ymd000000', strtotime("-30 days"));
    			$fsdt = date('Ymd235959', strtotime("now"));
    			$from_where .= " AND (link_published_date >= $tsdt AND link_published_date <= $fsdt) ";
    		}
    Now, in sidebar_stories_u.php, edit the code to call the filter you want to use:

    7 days:

    Code:
    else {	
    		$ss->filterToTimeFrame = 'last7days'; // filter the last 7 days	
    		$ss->header = $main_smarty->get_config_vars("PLIGG_Visual_Recently_Pop");
    	}
    OR

    30 days:

    Code:
    else {	
    		$ss->filterToTimeFrame = 'last30days'; // filter the last 30 days	
    		$ss->header = $main_smarty->get_config_vars("PLIGG_Visual_Recently_Pop");
    	}

  10. #10
    Pligg Donor abraxas's Avatar
    Joined
    Feb 2008
    Posts
    97
    Awesome, thank you very much. It's working now.

Similar Threads

  1. Limit Number of Days for Voting
    By krisrichards in forum Questions & Comments
    Replies: 2
    Last Post: 02-25-2012, 08:28 PM
  2. where is sidebar_stories_u.php ?
    By etrader in forum Questions & Comments
    Replies: 10
    Last Post: 08-10-2010, 12:49 PM
  3. , TOP in "24 hours", "7 Days", "30 Days" "365 Days" option
    By indiarun in forum Questions & Comments
    Replies: 1
    Last Post: 02-19-2010, 10:02 AM
  4. Sort top stories by number of days
    By ditto in forum Questions & Comments
    Replies: 0
    Last Post: 03-09-2008, 03:38 PM
  5. Number of Days to keep posting
    By ReggieW in forum Questions & Comments
    Replies: 2
    Last Post: 12-05-2007, 09:15 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •