Forum

Thread tagged as: Problem, Blog, CKEditor

Problems updating blog app

I've just upgraded to the current version of Perch no problem as far as I can tell. I then attempted to update the blog app from, I think, version 3.0.1. The following is from perch/addons/apps/perch_blog:admin.php

$this->register_app('perch_blog', 'Blog', 1, 'A simple blog', '3.0.1');
$this->require_version('perch_blog', '2.0.2');

I copied the latest version of perch_blog flder into /perch/addons/apps and also the new template files into perch/templates/blog.

However all the content added via the text editor (CKeditor) disappeared. I updated to the latest version of CKeditor.

I have now reverted to the old version of the blog and CKeditor and the content is displaying as it should.

Any ideas as to whare I may have gone wrong?

I'm planning on installing the events app. Do I need the latest version of the blog app?

Thanks Alan

Alan Rowe

Alan Rowe 0 points

  • 6 years ago
Rachel Andrew

Rachel Andrew 394 points
Perch Support

Did you update your templates as explained in the documentation?

https://docs.grabaperch.com/addons/blog/installation/

I decided to go with the suggestion in the documentration... "The easiest way to do this might be to take the new default templates and re-customise it to fit your site."

So, I copied the new templates over my existing perch/ templates/blog files as it seemed a more straightforward approach. I then changed the editor from the default to CKeditor, but that was the only change I made to the new templates.

All the blog posts remained available in the back end but the content was missing from the text editor fields.

Did I miss something? Thanks.

Rachel Andrew

Rachel Andrew 394 points
Perch Support

Did your old templates have the exact same field names as in the new ones, if not then I would expect your content to disappear.

Please show us your post.html template.

Ok, here you go. Thanks.

<div class="hentry">
    <h2><a href="post.php?s=<perch:blog id="postSlug" />" rel="bookmark" class="entry-title"><perch:blog id="postTitle" type="text" size="xl" /></a></h2>
    <p class="entry-published date"><perch:blog id="postDateTime" format="%d %B %Y" /> 
        <perch:if exists="authorGivenName">by <perch:blog id="authorGivenName" /> <perch:blog id="authorFamilyName" /></perch:if>
    </p>
    <perch:if exists="image">
        <div class="postImg group"><img src="<perch:blog id="image" type="image" width="320" height="240" crop="true" label="Image" />" alt="<perch:blog id="postTitle" />" /></div>
    </perch:if>
    <div class="description entry-content">
        <perch:blog id="postDescHTML" type="textarea" encode="false" editor="ckeditor" html="true" size="xxl" />
    </div>
</div>

<perch:blog id="excerpt" type="textarea" label="Excerpt" textile="true" order="1" suppress="true" size="s" />
<perch:blog id="image" type="image" width="50" height="50" crop="true" suppress="true" />
Drew McLellan

Drew McLellan 2638 points
Perch Support

Did your old templates have the exact same field names as in the new ones?

Hmmm... the problem is it's a while since I set the templates up and I can't honestly remember what changes I made to the default template files. Please excuse the question but can you clarify what you mean by field names?

The example (above) of my current post.html is obviously different from the new default post.html file. I gather this is the file i need to amend... I've read the installation documentation but confess I find it a bit confusing.

I just checked my apps.php it has the old code:

<?php
    include(PERCH_PATH.'/core/apps/content/runtime.php');
    include(PERCH_PATH.'/addons/apps/perch_blog/runtime.php');

?>

Should I change it to:

<?php
    $apps_list = array(
        'content',
        'categories',
        'perch_blog',
    );
?>
Drew McLellan

Drew McLellan 2638 points
Perch Support

It's worthing changing your apps.php yes.

Are the IDs in the template the same?

Mostly. The old file has id="postSlug" instead of id="postURL" apart from that the IDs that I have in my file are the same.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok great.

If you add debug to your page, that's not displaying posts, what does it output?

I've updated the blog app and the blog template files and added debug.

I'm getting the following on the backend:

Debug Message
SELECT u.*, r.* FROM perch_users u, perch_user_roles r WHERE u.roleID=r.roleID AND u.userEnabled=1 AND u.userID=1 AND u.userHash='dbb11afbf05141af45e008d6945f2761' LIMIT 1
UPDATE perch_users SET userHash='f21099895980b47c927d6e04468a574f' WHERE userID=1
SELECT p.privKey FROM perch_user_privileges p
SELECT * FROM (SELECT DISTINCT settingID, settingValue FROM perch_settings WHERE userID=1 OR userID=0 ORDER BY userID DESC) AS settings GROUP BY settingID
SELECT * FROM perch_blog_authors WHERE authorEmail='bignose@alanrowe.com' LIMIT 1
SELECT * FROM perch_blog_sections ORDER BY sectionTitle ASC
SELECT * FROM perch_blog_posts WHERE postID=19
Looking up missing property postTemplate
SELECT postTemplate FROM perch_blog_posts WHERE postID='19'
Invalid query: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'postTemplate' in 'field list'
Using template: /templates/blog/post.html
SELECT COUNT(*) FROM perch_blog_comments WHERE commentStatus='PENDING'
SELECT * FROM perch_categories c, perch_category_sets s WHERE c.setID=s.setID AND s.setSlug='blog' ORDER BY catTreePosition ASC
Adding:
Adding: Default
SELECT * FROM perch_blog_authors ORDER BY authorFamilyName, authorGivenName ASC
Queries: 11

The following on the blank post:


Debug Message SELECT * FROM perch_blog_posts WHERE postStatus='Published' AND postDateTime<='2015-02-09 10:37:00' AND postSlug='2014-10-30-doovoodoo' SELECT DISTINCT settingID, settingValue FROM perch_settings WHERE userID=0 Looking up missing property postTemplate SELECT postTemplate FROM perch_blog_posts WHERE postID='19' Invalid query: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'postTemplate' in 'field list' Using template: /templates/blog/ SELECT SQL_CALC_FOUND_ROWS DISTINCT tbl.* FROM ( SELECT idx.itemID, main.*, idx2.indexValue as sortval FROM perch_blog_index idx JOIN perch_blog_posts main ON idx.itemID=main.postID AND idx.itemKey='postID' JOIN perch_blog_index idx2 ON idx.itemID=idx2.itemID AND idx.itemKey='postID' AND idx2.indexKey='_id' WHERE 1=1 AND ((idx.indexKey='postSlug' AND idx.indexValue='2014-10-30-doovoodoo')) AND idx.itemID=idx2.itemID AND idx.itemKey=idx2.itemKey GROUP BY idx.itemID ) as tbl WHERE (postStatus='Published' AND postDateTime<='2015-02-09 10:37:00' ) GROUP BY itemID ORDER BY sortval ASC LIMIT 0, 10 SELECT FOUND_ROWS() AS `count` Looking up missing property postTemplate SELECT postTemplate FROM perch_blog_posts WHERE postID='19' Invalid query: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'postTemplate' in 'field list' Using template: /templates/blog/ SELECT * FROM perch_blog_comments WHERE 1=1 AND postID='19' AND commentStatus='LIVE' ORDER BY commentDateTime ASC Using template: /templates/blog/comment.html Fetching from cache: perch_blog_categories589c7a634eb12f2ec225cfedc7dc78ae Cache file not found: perch_blog_categories589c7a634eb12f2ec225cfedc7dc78ae SELECT setID FROM perch_category_sets WHERE setSlug='blog' LIMIT 1 SELECT main.* , COALESCE(cc.countValue,0) AS `count.blog.post` FROM perch_categories main LEFT OUTER JOIN perch_category_counts cc ON cc.catID=main.catID WHERE 1=1 AND setID='1' AND (cc.countType='blog.post' OR cc.countType IS NULL) AND cc.countValue > 0 ORDER BY catTreePosition ASC Using template: /templates/blog/category_link.html Fetching from cache: perch_blog_tags6ea7442106790571c75e0342c3a255ef Fetching from cache: perch_blog_date_archive_years8020c9cc794c6ec9bc919b1b53a6c73d Fetching from cache: perch_blog_date_archive_monthsf2e7d49784704a5b24102a78c349d57c
Drew McLellan

Drew McLellan 2638 points
Perch Support

This bit is worrying:

Using template: /templates/blog/

Why is there no template specified?

Not sure. As I mentioned I set the blog up a few years back when I knew even less than I do now...if that's possible!

Can you tell me where and how I should specify a template? Thanks.

Drew McLellan

Drew McLellan 2638 points
Perch Support

What does the code on your page look like where you're trying to display the posts?

The archive links, tags etc all display. But the post itself doesn't.

This is the code from post.php which is in root folder/blog I tweaked them when I set things up way back. I'm not sure where to find the post.php page in the new perch_blog install.

    <div id="content">
            <!--<h1>Blog: article page</h1>-->

            <div class="post">
                <?php perch_blog_post(perch_get('s')); ?>
                <?php perch_blog_post_comments(perch_get('s'), array(
                        'count'=>10
                )); ?>

                </div>
        </div>

This is what I get when I view source.

        <div id="content">
           <!-- <h1>Blog: article page</h1>-->

            <div class="post">

            </div>
        </div>
Drew McLellan

Drew McLellan 2638 points
Perch Support

Do you have a post.html template?

Yes I have the templates from updated version of the blog app perch_blog_v4.5.4/addons/apps/perch_blog/templates copied into perch/templates/blog

I kept my old post.html (along with the others) in a folder renamed blog-old so I can easily restore and edit them if needed.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok. I'm not sure what's going on. Is there anything else you can tell me?

Not really. I'm wondering if I need to replace the files inside /root/blog eg post.php with the equivalent files rom the new install? I notice index.php now uses several includes unlike the old version.

I'll give that a go and see what happens.

Alternatively I could revert to the old version of the blog. Would running this be a problem? Or maybe copy and paste the post contents into the new blog.

I'm working on a local version recently downloaded so can copyand paste from the live site. Luckily my client doesn't post that often!

Sorry, I don't know what else I can tell you.

Drew McLellan

Drew McLellan 2638 points
Perch Support

You could try the example files and see if they work - in a different folder if needs be.

Update: I added the new files to the root/blog folder and got a completely blank page.

Reverting to the original index.php the posts page displays evrything except the post itself.

I confess I'm confused over the specific roles of post.html and post.php. The following is in post.php

<div id="content">
            <h1>Blog: article page</h1>
            This is the template for posts!
            <div class="post">
                <?php perch_blog_post(perch_get('s')); ?>
                <?php perch_blog_post_comments(perch_get('s'), array(
                        'count'=>10
                )); ?>

                </div>
        </div>
 <h1>Blog: article page</h1>
This is the template for posts!

displays so it seems

   <div class="post">
                <?php perch_blog_post(perch_get('s')); ?>
                <?php perch_blog_post_comments(perch_get('s'), array(
                        'count'=>10
                )); ?>

                </div>

Is related to the problem. Unfortunately I don't have a clue.

The code for the current post.html page is

<article class="h-entry">
    <h1>
        <a href="<perch:blog id="postURL" type="hidden" />" rel="bookmark" class="p-name">
            <perch:blog id="postTitle" type="text" label="Title" required="true" size="xl autowidth" order="1" />
        </a>
    </h1>
    <p class="meta">
        <time class="dt-published" datetime="<perch:blog id="postDateTime" type="date" label="Date" time="true" format="Y-m-d H:i:s" divider-before="Meta information" />">
            <perch:blog id="postDateTime" type="date" time="true" format="%d %B %Y" /> 
        </time>
        <perch:if exists="authorGivenName">
            by <span class="p-author h-card"><perch:blog id="authorGivenName" type="hidden" /> <perch:blog id="authorFamilyName" type="hidden" /></span>
        </perch:if>    
        <perch:categories id="categories" set="blog" label="Categories" display-as="checkboxes">
            <a href="archive.php?cat=<perch:category id="catSlug" type="slug" />" class="p-category">
                <perch:category id="catTitle" type="text" />
            </a>
        </perch:categories>

    </p>
    <perch:if exists="image">
        <div>
            <img src="<perch:blog id="image" type="image" width="320" height="240" crop="true" label="Image" order="4" />" alt="<perch:blog id="postTitle" />" />
        </div>
    </perch:if>
    <div class="description e-content">
        <perch:blog id="postDescHTML" type="textarea" label="Post" order="2"  editor="ckeditor" html="true" size="xxl autowidth" required="true" />
    </div>
</article>

<perch:blog id="excerpt" type="textarea" label="Excerpt" markdown="true" order="3" suppress="true" size="s" />
<perch:blog id="image" type="image" width="50" height="50" crop="true" suppress="true" />

In the backend on the edit post page the following debug message:


Debug Message SELECT u.*, r.* FROM perch_users u, perch_user_roles r WHERE u.roleID=r.roleID AND u.userEnabled=1 AND u.userID=1 AND u.userHash='4844f59b52a08fefd5e2e3345db3c393' LIMIT 1 UPDATE perch_users SET userHash='10f88e3073f214190965248a39e2d750' WHERE userID=1 SELECT p.privKey FROM perch_user_privileges p SELECT * FROM (SELECT DISTINCT settingID, settingValue FROM perch_settings WHERE userID=1 OR userID=0 ORDER BY userID DESC) AS settings GROUP BY settingID SELECT * FROM perch_blog_authors WHERE authorEmail='bignose@alanrowe.com' LIMIT 1 SELECT * FROM perch_blog_sections ORDER BY sectionTitle ASC SELECT * FROM perch_blog_posts WHERE postID=19 Looking up missing property postTemplate SELECT postTemplate FROM perch_blog_posts WHERE postID='19' Invalid query: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'postTemplate' in 'field list' Using template: /templates/blog/post.html SELECT COUNT(*) FROM perch_blog_comments WHERE commentStatus='PENDING' SELECT * FROM perch_categories c, perch_category_sets s WHERE c.setID=s.setID AND s.setSlug='blog' ORDER BY catTreePosition ASC Adding: SELECT * FROM perch_blog_authors ORDER BY authorFamilyName, authorGivenName ASC Queries: 11

This is in red:

Invalid query: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'postTemplate' in 'field list'
Using template: /templates/blog/post.html

It's difficult to know what to look for without understanding PHP!