We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 51020
    • 670 Posts
    Hi There,

    I have a listing of events - these events expire after a certain date, but do not get unpublished - because we want to show past events too on certain pages.

    But, in the menu, I only want to show current events.

    I have a getResources call for the main page, which works a treat, as it just filters the results by a TV called EventDate and I have a snippet called curDate which it checks against. It the event date is prior to the current date, it's omitted from the results:

    &tvFilters=`EventDate>=[[curDate]]`
    



    But - my main menu is using Wayfinder, and I cannot see a way to filter by a TV - is this possible?
    Or do I need to change to pdoMenu? (Although not sure I can do this in there either?)

    I thought I could use the 'where' statement - but I don't know where to start with that!!

    Thanks in advance for any help!

    Andy

      • 36926
      • 701 Posts
      Not sure it's possible in wayfinder, but I think pdoMenu uses all the general setting which pdoTools has.
      https://docs.modx.pro/en/components/pdotools/general-settings.

      So the same tvFilterrs parameter you are using should also work.
        • 51020
        • 670 Posts
        Quote from: bennyb at Apr 11, 2017, 12:22 PM
        Not sure it's possible in wayfinder, but I think pdoMenu uses all the general setting which pdoTools has.
        https://docs.modx.pro/en/components/pdotools/general-settings.

        So the same tvFilterrs parameter you are using should also work.

        Thanks - i have installed pdotools, and set up PdoMenu - but when I add the &tvFilter variable, the results are unexpected.

        I have:
        &tvFilters=`EventDate>=[[curDate]]`
        


        Now my menu is only showing resources that include the TV 'EventDate'.
        What I actually want it to do is show all the other menu items, but OMIT results who's event date is in the past.

        This is my full call:

        [[pdoMenu?
                &parents=`0`
                &level=`2`
                &tplOuter=`WayfinderOuterTpl`
                &tplParentRow=`WayfinderParentRowTpl`
                &parentClass=`dropdown`
                &includeTVs=`EventDate`
                &tvFilters=`EventDate>=[[curDate]]`
            ]]
        


        So to summarise, I want to show all resources within resource tree, but Omit any resources who's EventDate is in the past.

        What am I missing?

        Thanks!
        Andy
          • 37105
          • 194 Posts
          Just take note that when working with snippets returning flexible data its better to call that snippet uncached!
          So its better to call it like this:
          &tvFilters=`EventDate>=[[!curDate]]`


          Can you post your snippet also?
            Codeplaza Webdesign: for professional websites at low cost
            • 51020
            • 670 Posts
            Hi - OK thanks - but the same call work perfectly with get resources on another page, so I assumed all this was fine.

            This is my Snippet:

            <?php
            return date('Y-m-d H:i:s');
            
              • 51020
              • 670 Posts
              Quote from: donquicky at Apr 11, 2017, 09:42 PM
              Just take note that when working with snippets returning flexible data its better to call that snippet uncached!
              So its better to call it like this:
              &tvFilters=`EventDate>=[[!curDate]]`


              Can you post your snippet also?

              I have changed the call to:
              &tvFilters=`EventDate>=[[!curDate]]`
              

              But now nothing s showing in my navigation at all!

              Any ideas?
                • 52064
                • 120 Posts
                try add:
                     &processTVs=`EventDate`
                
                  FerX - Developer at Eracom s.r.l.
                  • 51020
                  • 670 Posts
                  Yep - already tried that - still nothing showing:
                  
                  [[pdoMenu?
                          &parents=`0`
                          &level=`2`
                          &tplOuter=`WayfinderOuterTpl`
                          &tplParentRow=`WayfinderParentRowTpl`
                          &parentClass=`dropdown`
                            &includeTVs=`EventDate`
                           &processTVs=`EventDate`
                          &tvFilters=`EventDate>=[[!curDate]]`
                      ]]
                  


                    • 52064
                    • 120 Posts
                    change curDate snippet.
                    pdo not convert timestamp to string

                    <?php
                    return time();
                    
                      FerX - Developer at Eracom s.r.l.
                      • 51020
                      • 670 Posts
                      Quote from: ferx77 at Apr 12, 2017, 03:35 PM
                      change curDate snippet.
                      pdo not convert timestamp to string

                      <!--?php
                      return time();
                      
                      -->

                      Thanks - this doesn't seem to make any difference though. It still returns nothing when uncached, and returns ONLY my events when cached (and not standard resources such as home, about etc which don't have any event date).

                      Back to the original problem, I want to output all resources (including all those that are not events), but OMIT all those events that are in the past.

                      I'm thinking this must be wrong:
                      &tvFilters=`EventDate>=[[!curDate]]`


                      as it's filtering ONLY resources with an event date.

                      I think the tv filter should effectively say 'show all resources, but if the resource has an event date, and is in the past, don't show that'. but I have no idea how to construct this.


                      Does this make sense?

                      Thanks in advance, for any further pointers!

                      Andy