We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9496
    • 113 Posts
    After sort of solving the specific date ditto listing, now I am trying to cover listings that are ongoing, meaning there is no unpub_date (which is what I use to sort specific events) rather thee is a TV called "ongoingEventDay" that is set up as a dropdown list with "Monday, Tuesday...etc..." with a default of nothing.

    The problem I am running into is comparing that value of the tv to the current day of the week.

    In a nutshell, look to see what day it is today and filter out anything that is not on that day.

    I thought the strftime %A would return "Sunday, Monday etc..." So I set up my ditto call like so...

    [!Ditto? &parents=`53,54,49,52,50,53,55` &noResults=`no events scheduled` &display=`all` &sortDir=`ASC` &dateSource=`ongoingEventDay` &tpl=`eventEntry` &filter=`ongoingEventDay,@EVAL return strftime("%A");,1`!]


    Which I would think would filter out anything that is not equal to todays day of the week. For instance today is Friday, and in theory at least should exclude any entry that doesnt have friday in the list, right? Or am I missing something (wouldnt be the first time...)
      • 33372
      • 1,611 Posts
      You could probably do this a number of ways, but I think that I would do it as a tagging Ditto call instead of a filtered date call. You can define your ongoingEventDay TV as your tag source and just feed the Ditto call the current weekday as matching text. The easiest way to do that might be to create a TV that @EVALs to the current weekday and then use it in your Ditto call, e.g.:

      [!Ditto? &parents=`3` &summarize=`10` &total=`10` &tpl=`eventTpl` &paginate=`0` &alwaysshow=`1` &orderBy=`pagetitle ASC` &displayArchive=`0` &depth=`1` &trunc=`0` &tagDelimiter=`,` &tagData=`tvongoingEventDay` &tagMode=`onlyTags` &tags=`[*weekday*]`!]
        "Things are not what they appear to be; nor are they otherwise." - Buddha

        "Well, gee, Buddha - that wasn't very helpful..." - ZAP

        Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
        • 9496
        • 113 Posts
        Zap-
        Thanks. I will experiment with that.

        I am essentially trying to pull event listings using an unpub_date which I have gotten to work, and also pull recurring event listings which don’t have an unpub_date and then display all that goodness on the appropriate day and date.

        Ive figured how to do it through a combination of two ditto calls (one for fixed events (with a unpub_date) and one for ongoing daily events (no unpub_date) which works but seems kind of ungainly....

        I am kind of building this plane while I’m flying it so to speak, so its off to learn about tags and see if I can logically combine the two...

        thanks again-
        P
          • 9496
          • 113 Posts
          So I gave it a try but I cant seem to get it to work.... something to do with the @eval in the &tags=`` parameter.

          I am not quite sure what you meant by the [*weekday*] tv in that example call. I tried creating one, used input type: text

          and used this:
          @EVAL return strftime("%A", strtotime('now'));



          Then I call it on my template with this ditto call:

          [!Ditto? &parents=`53,54,49,52,50,53,55` &display=`all` &sortDir=`ASC` &tpl=`eventEntry` &tagData=`tvongoingEventDay` &tags=`[*weekday*]`!]


          I’m not sure why it needs to be a tv though. Shouldnt it be a snippet? I’m kind of lost. If it is a tv and I set it to a dropdown list, wouldnt the value change depending on the current day?

          BTW you can see what I am trying to accomplish here...
          http://beta.akronicity.com/events/this-week
          The Multiple Ditto header calls is what I am looking to do. (just somewhat of a cleaner version)
            • 33372
            • 1,611 Posts
            You can try a snippet as well. Nesting snippets within snippets can be tricky, but usually if you vary the caching status (one cached and one uncached) it will work. You’d need to make the page uncached in order for the weekday TV that you have now to update consistently.
              "Things are not what they appear to be; nor are they otherwise." - Buddha

              "Well, gee, Buddha - that wasn't very helpful..." - ZAP

              Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
              • 9496
              • 113 Posts
              nice. It was the cache (I had the listing page cached) I unchecked it and it worked...I’m still exploring the possibilities of tagging vs. filtering vs. extenders or in combinations thereof, maybe I should write it down eh?

              P
                • 9496
                • 113 Posts
                So after several rounds of experimentation I finally came up with something that works. I decided to create extenders to house the filters, since it seemed (at 3am anyway) the easiest thing to get a handle on.
                Basically the ultimate goal was to have a weekly listing of events, sorted by their unpublished date as well as show ongoing events for the appropriate day. These listings unpublished date returns a 0, but have a tv with the day attached to the entry template. The single events, however had nothing attached to the ongoingEvents tv so I created another default choice, "single" so I didn’t have to worry about it.

                With this I had to set up 7 extenders (one for each day) to return the proper entries so my ditto call looks like this:
                [!Ditto? &parents=`53,54,49,52,50,53,55` &display=`all` &sortDir=`ASC` &tpl=`eventEntry` &extenders=`eventListFilter` !]


                and the eventListFIlter code is:

                <?php
                
                $filters["custom"]["eventListFilter"] = array(array("unpub_date","ongoingEventDay"),"eventListFilter");
                
                
                if (!function_exists("eventListFilter")) {
                	function eventListFilter($resource) {
                		if ($resource['ongoingEventDay'] == ("single") && ($resource['unpub_date'] < strtotime("11:59 pm")) || ($resource['ongoingEventDay'] == strftime("%A", strtotime('now')))
                		){
                			
                			return 1;
                			} else {
                			return 0;
                			}
                			}
                }
                
                ?>


                I had to tinker with it so I could use both the unpub_date & ongoingEventDay tvs to determine what to display. Getting that array right was my biggest hurdle (had to look at the exampel a few times) I am so not a php guy beyond the basics but this was the only way I could figure it out with my very limited mental toolbox.

                So the question is, is there any downside to doing it this way? Like I said, I could have done it with multiple ditto calls or probably tagging like you suggested. There is simply so much flexibility I can’t really get my head around it, but I don’t know enough about the complete MODX/Ditto package to make anythng but the limited "Well it works..."

                The result is here http://beta.akronicity.com/events/this-week

                you can bounce through the other things to do as well (although they may not have as many entries, still gotta do that, uugh)
                and as always, thanks for all of your help-
                P




                  • 33372
                  • 1,611 Posts
                  There are usually many ways to accomplish any given task in MODx, and Ditto/PHx multiplies the possibilities. The right way is whatever seems best to you. MODx’s caching feature means that it doesn’t really matter that much whether one method requires a few more CPU cycles than another on cached snippets or pages, either.
                    "Things are not what they appear to be; nor are they otherwise." - Buddha

                    "Well, gee, Buddha - that wasn&#39;t very helpful..." - ZAP

                    Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options