Forum
Blog Issue With Posts
I am having some issues with a site (not sure when these started but perhaps after an update)
Perch: 2.7.2, PHP: 5.4.28, MySQL: 5.1.59, with PDO Server OS: Linux, cgi-fcgi
All posts appear to be fine in admin and display on the listing pages. However clicking an article only displays the heading. The url has this in the link:
/blog/1970-01-01-bedford-dentist-recognized-by-the-british-dental-association
Whats causing this? I tried creating an article from scratch and its still adding this weird date. I suspect this creation date is causing the issue but not sure how its got like that.
Is your post template missing a date field?
Okay that seems to have sorted the date and article display. Something else seems to have changed about the display I had set up for the category links. I think its connected with the release of the Categories app.
I have a list of Categories displayed in a sidebar to show the Categories with a count next to each showing quantity of articles e.g. Practice News (2). However I had to fiddle with this code to get it working again.
But two issues remain different.
Here is code:
Also how do I display the url in this without the ?cat= as a clean url, I did this for posts in .htaccess
The changes for category counts are as detailed in the documentation here: https://docs.grabaperch.com/addons/blog/installation/
qty needs to change to count.blog.post.
Just change the value of href to whatever is correct for your rewrite rules.
Thanks, I stumbled on the changes last night and got qty working.
However, previously even empty Categories displayed e.g. Industry News (0) but now they only display if they have articles.
Is there a way to restore this way of working?
This is the code I now have in my category links template:
Finally these category links appear on the article detail page, but the url does not display the categories but changes to the url of the article its displaying on, how can I fix this?
What should the URL be?
/news/?cat=practice-news
however on an article page its: /news/my_article_title/?cat=practice-news
Also even though I have the empty => true inside the listing and detail pages call to the links template its no longer showing empty categories (it did before).
Ok, so how about setting the link to that?
Wouldn't that solve it?
That works, thanks. How about the other issue?
Even though I have the include-empty => true inside the listing and detail pages call to the links template its no longer showing empty categories (it did before).
Yes, I don't know about that.
Could it be a bug, it worked before. In fact I think it was adapted from code you kindly provided.
Before being when?
Well unfortunately I cannot be sure as I only spotted it was not working right when I was trying to add a blog feature to another site and was referencing the code for this site.
I think it might be after updating the Blog app from 4.5.2 but it could have been after updating to 2.7.2.
Right, so as a result of a change rather than just randomly stopping working?
Yes correct, checked docs and its done the correct way.
Just checked the testing version of this site, its using perch_blog 4.1 and it displays empty categories using the same code as above. So maybe there is something missing in perch_blog 4.5?
FYI Did a bit of testing. If I place the category_link template in the category folder in templates and call it from there there empty categories show. However the count.blog.post no longer works.
2 steps forward 1 back!
So studying the contents of blog 4.1 and blog 4.5 seems the code for include-empty is inside PerchBlog_Categories.class.php which is no longer in blog 4.5 probably because its no longer used by the blog app but by categories.
However by calling the template inside /category in templates breaks whatever drives the count.blog.post
Maybe you can shed some light?
Ok, sounds like you'll either need to stick with the old version or go without it for now.
Okay shame.
I think its something in this code which is in the original PerchBlog_Categories.class.php file which is no longer in the app.
This seems to be missing from the PerchCategories_Categories.class.php file. There is some code about include-empty at line 154 but maybe its missing some extra lines. As I am no php coder its beyond me!
Only posting this in case it helps...
It's ok, I've fixed it.