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

    I have a TV called apToDate.

    How can I use the NewsListing filter property to only show documents where apToDate is greater than or equal to the current date.

    i.e. tvapToDate >=CurrentDate

    Below is how I call NewsListing
    $snippetName= 'ap-NewsListing';
    $snippetParams=array('summarize'=>4,
                         'multilevel'=>1,
                         'truncText'=>"Read More",
                         'hidefolders'=>"true",
                         'truncSplit'=>"false",
                         'tpl'=>"ap-listing-home",
                         'dateformat'=>"%b %d, %Y",
                         'showarch'=>"false",
                         'archplaceholder'=>1,
                         'emptytext'=>"No content available",
                         'paginate'=>1,
                         'prv'=>"ap-paginate-prv",
                         'nxt'=>"ap-paginate-nxt");
    
    ...
    
    //-- condition if EVENTS folder is TRUE
    else if($modx->documentObject['id'] == 16){
    	$snippetParams['summarize'] = 4;
    	$snippetParams['tpl'] = "ap-listing-channelEvents";
    	$snippetParams['srotby'] = "apEventFromDate";
    	$snippetParams['truncText'] = "Details";
    	
    	$docID=$modx->documentObject['id'];
    	$snippetParams['startID'] = $docID;
    	$outstring='<div class="brief event cf"><dl>';
    	$outstring.=$modx->runSnippet($snippetName, $snippetParams);
    	$outstring.='</dl></div> <!-- /event --><hr />';
    }


    I’d ike to thank in advance for all your time and efforts.

    regards,

    -raavi
      • 25663 MODX Staff
      • 12,272 Posts
      Which version of Newslisting are you using? (And I’d also suggest getting Ditto, the successor to NL.)
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 18397
        • 3,250 Posts
        Assuming you are running the latest release of NewsListing or Ditto, you would use the following param:

        &filter=`tvapToDate,CURRENTDATEGOESHERE,>=`
        


        This will only work if you are storing apToDate as a unix timestamp. If you need an explanation of how to do this, search the forums as there was a similar thread a few weeks back.

        Hope this helps.
          • 24278
          • 165 Posts
          rthrash,

          I am using NL 6.4.2

          Mark,

          Thank you for your suggestions. I appreciate that.

          My TV name is "apEventToDate" so should I pass it to the &filter as apEventToDate or tvapEventToDate?

          ALso, I use the DATE input type to store the value for the TV apEventToDate and the value stored in the mySQL database is for e.g. 21-05-2006 20:57:18, please can you point me to a resource where by I can learn to store the value as a unix timestamp or convert the value to unix timestamp before comparing it with the current date/time.

          I am new to modx and php and can use all the suggestions smiley.

          warm regards,

          -raavi