Please help me understand the publication date on a blog post. I’ve written a post that I want to be published on Jan 1st, and I’ve entered that into the publication date. I’m testing with a browser in private mode, not logged into Backlight.
My expectations:
post does not appear on the blog home page
date in the blog post (viewable by admin) to be the chosen publication date
trying to access the post while not logged in should return 404
Reality
post does appear on the blog home page
date in the blog post is the date/time I saved the post
clicking into the post when not logged in results in 404
The top 2 entries are both post-dated to Jan 1st, 2025, so I don’t think they should appear unless there is an admin user logged in. Instead, they appear in the list of blog entries but return a 404 if a non-admin user clicks on them. I would also like them to have the publication date instead of the created date.
This is probably not the “best” way to fix it, but I dug in and found the offending code. The loop in backlight/modules/kookaburra-blog/dynamic/view/index.php, line 85, is not checking the publication date nor the expiration date. There is existing code to do this check but it’s in the ContentNodeDAO (isItemPublished) and isn’t accessible from here (which is why I’m not convinced this is the best way to fix this).
Not thoroughly tested.
backlight/modules/kookaburra-blog/dynamic/view/index.php, starting at line 85:
removed - we don't recommend or encourage editing BL code
This doesn’t fix the creation date being displayed instead of the publication date, but I can see why that is happening, I just haven’t changed it. Also need to look into displaying the publication date when the full article is displayed.
Continuing to dig for a better solution, I’m looking at BlogDAO::getAllBlogs(). This function starts by loading all the top level blogs (parentId is null), which are filtered based on publication date. It then iterates over the top level blogs loading the children for each. The children are not filtered by the publication date, which doesn’t seem correct to me.
I tried adding the code to filter the children to see if it solves my original problem but unfortunately it did not. I still think that filtering should be done though, potentially fixing other problems I haven’t run into (yet).
backlight/modules/module-publisher/application/dao/BlogDAO.php, line ~133
removed - we don't recommend or encourage editing BL code
Going back to index.php, I don’t know how $blogItem gets its value and I don’t know Tcl well enough to quickly track it down (won’t stop me from trying though), but I expect that’s where the best fix is going to be.
Thanks @Ben, I did the update and the publication date is working much better now.
One small issue is that the date format setting is no longer being respected. I have my blog date format set to only show the date without the time, but after the update it is always including the time. This is happening with both post-dated blog entries, and already published blog entries.
Hi @mikealex, this isn’t new behaviour. After some investigation I’ve found that the date format sticks with your browser session. That means it won’t change for you until your session expires or you view the blog in a different browser. You can see the change has taken effect by viewing the blog in a new private window.
I don’t have any suggestions to improve this behaviour.