Forum
Blog functions don't return any content
Hello,
I have a problem making Blog work on my website.
I have the following function on my homepage:
<?php
perch_blog_custom(array(
'count' => 1,
'template' => 'latest.html',
'sort' => 'postDateTime',
'sort-order' => 'DESC',
));
?>
This homepage template is located in perch/templates/pages/
. The template I'm calling here is located in perch/templates/blog
.
Besides the issue with the homepage, my Blog index.php
doesn't return any posts. It's using the default function <?php perch_blog_recent_posts(10); ?>
.
I struggle to find any reason why this wouldn't work. Any ideas?
Diagnostics:
Health check
Perch is up to date
PHP 5.6.36 is up to date
MySQL 5.6.37-log is up to date
Image processing available
Summary information
Perch: 3.1.2, PHP: 5.6.36, MySQL: mysqlnd 5.0.11-dev - 20120503 - $Id: 76b08b24596e12d4553bd41fc93cccd5bac2fe7a $, with PDO
Server OS: Linux, apache2handler
Installed apps: content (3.1.2), assets (3.1.2), categories (3.1.2), perch_blog (5.6.1)
App runtimes: <?php $apps_list = [ 'content', 'categories', 'perch_blog', ];
PERCH_LOGINPATH: /perch
PERCH_PATH: /var/www/vhosts/clientname/httpdocs/perch
PERCH_CORE: /var/www/vhosts/clientname/httpdocs/perch/core
PERCH_RESFILEPATH: /var/www/vhosts/clientname/httpdocs/perch/resources
Image manipulation: GD Imagick
PHP limits: Max upload 16M, Max POST 16M, Memory: 128M, Total max file upload: 16M
F1: 9fab42554990d2c203d599a6437edd2a
Resource folder writeable: Yes
HTTP_HOST: magdawebdesign.com
DOCUMENT_ROOT: /var/www/vhosts/magdawebdesign.com/httpdocs/
REQUEST_URI: /perch/core/settings/diagnostics/
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
Add-on versions
Blog 5.6.1 is up to date
Thanks.
If you turn on debug, what does it output for your blog listing page?
Hi Drew,
Below is the debug output:
Thanks.
Is it possible that somehow paths are not recognised on my Perch installation on the server?
It all looks fine - but there are no posts matching the criteria. How many posts do you have that are published and with a past date?
Hi Drew,
Thanks for replying.
There was one published post. I deleted it and created a new post (published). I still can't see this blog post. However, the following line appears in the post debug message:
I've also noticed I can't add any new post and no error message appears in the debug message.
Ok, that doesn't sound good. What's the history of this installation?
I was first developing the site locally. It's all working fine with my local database. Then I copied over the files to one hosting provider, created a new database there and imported the local database. I think I only updated db host, user, password and license on the production environment.
The problem started happening then but because I wasn't writing blog posts and was planning to move to a new hosting provider, I didn't look into that issue.
However, I moved the site to a new server over the weekend (also created a new database and moved my content) and the issue came back. I would like to change the profile of the site so it's quite important to make the Blog app work.
It would be great if you could help, Drew. I'm not an SQL expert so I don't really know at what is causing the problem.
Thanks.
When you get the "Invalid query" error, is there anything before it?
It happens when I try to save changes to an existing post (content changes are saved).
Here is the debug message (I've removed content bits so it's not too long):
Are you able to create a new post?
Actually no. When I click 'Save', I'm taken to the blank Post page and no new post appears in the list of posts in the admin area.
For some reason it looks like the post isn't being assigned an ID by the database when it's created. I have no idea why that would be.
Are there any errors in your server error log?
I've just asked my hosting provider. I'll come back with this shortly.
Hi Drew,
The hosting provider said there weren't any specific errors, just a few about blog image not loading. Is it helpful?
They also said: "As for the SQLSTATE error you received, this seems to be trying to import content to the SQL database to a location where content already exists. Unfortunately, it doesn't say specifically which table this is in either. It might be worth clearing the contents of the database and manually re-uploading."
If I delete database content, will I need to run Perch setup?
Thanks, Magda
Which tables are you looking to delete? You could try removing the
perch3_blog
tables and then just letting the Blog app recreate them.I'll do that.
It worked :) I'm so happy! Thanks Drew.
https://mobdro.ooo/
I also faced same issue but now it solved for me. Thank you for the help.