ventrian / News-Articles

News Articles for DNN has been helping DNN administrators to publish articles and blogs to their DNN portals since 2004.
MIT License
38 stars 24 forks source link

When in archive, variable or token for passed date #28

Open b-creative opened 5 years ago

b-creative commented 5 years ago

Hi all, We use News Articles for many things, also for a calender where it is important to show the future events (I use filter setting Show Pending for this). But when these dates (I set startdate and enddate) are passed I do not want the events to be visible anymore. This is standard for the normal listing but when I call a category listing I still see the events. Is there something I can do to prevent this? I was thinking about a new token... something like [ISPAST] or something. Or maybe there's a smart little workaround for this?

b-creative commented 5 years ago

Hi, Came up with a workaround. I added an attribute to the surrounding div in Listing.Item.html:

data-date="[PUBLISHSTARTDATE:yyyy-MM-dd]"

I added a jQuery script in Listing.Footer.html:

<script> $(document).ready(function(e) { $('div.media').each(function(index, element) { event_day = $(this).attr('data-date'); event_day = new Date(event_day); today = new Date(); if(event_day.getTime() < today.getTime()) { $(this).css('display','none'); } console.log($(this).attr('data-date')); }); }); </script>

Now I can call a category with filter setting 'Show pending' selected and have articles in the past hidden.