Forum

Thread tagged as: Blog

Displaying blog posts

Hi there

What is the easiest way to get it so blogs appear on the website, even if the published date is in the future?

I have modified the Blogs app to create a system where people can post offers.

I am using the in-built Date as the expiry date, so for example, a user will post an offer with an expiry date of 10 February 2015 but this won't appear until the published date, where actually it needs to display straight away.

Is this possible?

Rich

Rich Hemery

Rich Hemery 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes. If you've built your own stuff on top of Blog, then I can't really help much, but you should reverse the date filters on any of the database queries.

I haven't added anything extra on stop, it's just a few new fields for when someone creates an 'offer' or blog as it were. Could you please let me know the location of the database queries to reverse the filter?

Thanks

Drew McLellan

Drew McLellan 2638 points
Perch Support

In which case it doesn't sound like the blog is suitable for this.

Why are you not using a content region or a collection?

Because everything is set-up really nice with the Blogs app in terms of adding/edtining/deleting 'offers' through the dashboard.

Also the most important thing is privileges, all offers need to go through an approval process upon creation or edit, so the privilege system that comes in-built to the Blogs app is perfect.

I just need this one fix and it will all be good.

Drew McLellan

Drew McLellan 2638 points
Perch Support

The date is a published date. You could add an additional expiry date and then filter on that.

Setting up a second 'Expiry' date field is probably the more logical approach!

So we now have the default postDateTime

and my new expiry field, which I've called postDateTime2, getting a bit stuck with the filtering, it's currently using 'date' as the value, have tried postDateTime2 but not 100% sure what I'm doing here to be honest...

        <?php perch_blog_custom(array(
            'count' => 100,
            'template' => 'post_in_list.html',
            'sort' => 'postDateTime',
            'sort-order' => 'DESC',
            'filter' => 'expires',
            'match' => 'gt',
            'value' => date('Y-m-d H:i:s'),
        ));

?>

Drew McLellan

Drew McLellan 2638 points
Perch Support

I'd suggest calling your field expires or expires_on or something logical like that. postDateTime2 won't mean anything to anyone reading the code back.

If your field were called expires, then your filter would be correct.