We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9496
    • 113 Posts
    Just want to start off by saying a big thanks to all of the developers around here and I apologize in advance if this has been gone over before (I’ve been trying all day to figure this out and I am way new...)
    Essentially, what I am trying to do is a weekly event calendar, that uses ditto to display items as a list.

    Each event is set up using the un-publish date ($sortBy=`unpub_date` as the date of the event, so it will be removed once the event has passed. I figured this would be easier than adding a tv for an event date which seemed a bit redundant to me.

    For my event listing page, I would like to sort the listings on a daily basis going out one week, starting from today’s date.

    I have been able to get the events displayed by using the @eval and strtotime....

    This is the ditto call I use...
    <h2>today</h2>
    [!Ditto? &parents=`53,54,49,52,50,53,55` &noResults=`no events scheduled` &display=`all` &sortDir=`ASC` &sortBy=`unpub_date`  &dateSource=`unpub_date` &dateFormat=`%D` &tpl=`eventEntry` &filter=`unpub_date,@EVAL return strtotime("11:59 pm");,4`!]
    
    <h2>today +1</h2>
    [!Ditto? &parents=`53,54,49,52,50,53,55` &noResults=`no events scheduled` &display=`all` &sortDir=`ASC` &sortBy=`unpub_date`  &dateSource=`unpub_date` &dateFormat=`%D` &tpl=`eventEntry` &filter=`unpub_date,@EVAL return strtotime("11:59 pm +1 day");,4`!]
    
    <h2>today +2</h2>
    [!Ditto? &parents=`53,54,49,52,50,53,55` &noResults=`no events scheduled` &display=`all` &sortDir=`ASC` &sortBy=`unpub_date`  &dateSource=`unpub_date` &dateFormat=`%D` &tpl=`eventEntry` &filter=`unpub_date,@EVAL return strtotime("11:59 pm +2 day");,4`!]


    and this is the result:
    http://beta.akronicity.com/events/this-week

    It seems a bit ungainly but, like I said, I’m new and us noobs tend to code like three year-olds talk. WHich brings me to my question:

    Is there a way to filter using "and" versus or? Such as:

    "Ditto, will you please get me the events for tomorrow, but don’t include today’s events?"

    and "Ditto, will you please get me the events for the day after tomorrow, but don’t include today or tomorrows events?"
    and so on for the rest of the week. I am trying to wrap my head around it but I can’t for the life of me figure out a clear and logical way to do this...

    thanks in advance for any light you can shed on this -
    P


    p.s : I was thinking this might be a little more clear:

    today should exclude anything > 11:59pm today
    tommorow should exclude anything < 11:59pm today and > 11:59 tomorrow
    day after tomorrow should exclude anything < 11:59 tomorrow and >11:59 day after tomorrow

    and so on...I dunno maybe the logic is a bit broken...



      • 18397
      • 3,250 Posts
        • 9496
        • 113 Posts
        Mark, thanks for the heads up.
        I tried this solution and for examples sake I called it unpubdateFilter.extender.inc.php and placed it in the extenders directory.

        So now my ditto call is this
        [!Ditto? &parents=`53,54,49,52,50,53,55` &noResults=`no events scheduled` &display=`all` &sortDir=`ASC` &sortBy=`unpub_date`  &dateSource=`unpub_date` &extenders=`unpubdateFilter` &dateFormat=`%D` &tpl=`eventEntry` !]


        and the extender php file looks like this:
        <?php
        
        $filters["custom"]["unpubdateFilter"] = array("unpub_date","unpubdateFilter"); 
        
        if (!function_exists("unpubdateFilter")) {
        	function unpubdateFilter($resource) {
        		if ($resource['unpub_date']) < "11:59 pm" && $resource['unpub_date']) > "11:59 pm +1 day"{
        			return 1;
        		} else {
        			return 0;
        		}
        	}
        }
        ?>


        but that doesn’t work. I’m thinking I need to add the strtotime in there so it knows to pull todays date and go from there. But I can’t seem to put it together. Any thoughts and thanks again-
        P
          • 18397
          • 3,250 Posts
          Change
          if ($resource['unpub_date']) < "11:59 pm" && $resource['unpub_date']) > "11:59 pm +1 day"{
          

          to
          if ($resource['unpub_date'] < strtotime("11:59 pm") && $resource['unpub_date'] > strtotime("11:59 pm +1 day")){
          
            • 9496
            • 113 Posts
            Mark-
            Thanks. I figured it was that syntax issue within the extender.inc file. I gave it a whirl and it simply returned all of the events. I think I am unclear on the extender / filter relationship and how they work together.

            You can see the results here
            http://beta.akronicity.com/events/this-week (its at the bottom)

            I used this as the ditto call:
            [!Ditto? &parents=`53,54,49,52,50,53,55` &noResults=`no events scheduled` &display=`all` &sortDir=`ASC` &sortBy=`unpub_date`  &dateSource=`unpub_date` &dateFormat=`%D` &tpl=`eventEntry` &extenders=`unpubdateFilter`!]


            With the unpubdateFilter.extender.inc file being in the assets/snippets/ditto/extenders/ directory...

            I am thinking that I am not calling it right (do I need to use &filter as well, whats the proper order within the call itself, etc...) within the ditto call or there’s something I am just missing.


            On that note I did get the &filter=`@eval....` to work (which was the original problem) by cleaning up the ditto call.
            [!Ditto? &parents=`53,54,49,52,50,53,55` &noResults=`no events scheduled` &display=`all` &sortDir=`ASC` &sortBy=`unpub_date`  &dateSource=`unpub_date` &dateFormat=`%D` &tpl=`eventEntry` &filter=`unpub_date,@EVAL return strtotime("11:59 pm");,4`!]


            That being said, if I can manage to get the extender to work, theoretically I can create 7 (one for each day’s events) and use call those on multiple pages right? I have about 8 listing pages of various events. Versus having the raw code in each specific ditto call, on each specific template I guess I am simply trying to manage the amount of redundant raw php involved.

            I appreciate all of the help.
            P
              • 9496
              • 113 Posts
              So I figured out a way to do it without having to go the extender route. I used the &filter with the multiple @eval methods like I originally tried (and originally didnt work.) I created a chunk for the specific sections using [*id*] and then popped that into the section templates. Although for those page listings (e.g. "This Week") I had to code it directly into the page (because of multiple ID’s).

              For clarification purposes though, can you point me to something that explains when and more importantly why we should use the extender capability? Seems like (at least in my case) that simple evaluations within the ditto call work fine and are quite extensible. But again, I am essentially a third grader here, he he.

              thanks for all the help-
              P