Forum

Thread tagged as: Problem, Error, Blog

Blogging in the 1970s

Hi

We are having an issue where our blog listings link to new posts as …/1970-01-01-title-of-article

This only happens when we use our Staff Blog template (see template code below), if we use our News or Case Study template the links are fine.

Our blog article template:


<div class="news-article"> <article> <perch:help> <h6><strong>After you enter the title</strong>, scroll to the bottom and choose 'post type' from the dropdown, otherwise you <strong>will lose all entered data</strong></h6> </perch:help> <!-- <div class="feature story-page"> --> <perch:if exists="news_story_img"> <div class="main-img"> <img src="<perch:blog id="news_story_img" type="image" label="Main story image" help="Main header image for news page - 597px x 340px" order="4" />" alt="<perch:blog id="postTitle" />"/> </div> </perch:if> <!-- </div> --> <div class="news-story"> <p class="date-stamp"><perch:blog id="postDateTime" type="date" time="true" format="d F Y, H:i" native="false" label="Post date" order="40"/></p> <h2> <perch:blog id="postTitle" type="text" required="true" size="xl" html="true" order="1" label="Title"/> </h2> <perch:blog id="postDescHTML" type="textarea" encode="false" editor="markitup" textile="true" size="xxl" label="Body" required="true" order="2" /> <perch:blog id="post_type_title" type="select" label="Post type" options="Blog|Blog, News|News, Case study|Case study" allowempty="false" required="true" suppress="true" help="This menu tags the story in the news feed" order="39"/> <perch:blog id="tile_image" type="image" width="298" height="298" crop="true" suppress="true" label="Tile image" order="5" help="Tile image for homepage - 298px x 298px"/> <div class="contact_news"> <div class="profile_"> <img src="<perch:blog id="author_image" type="image" width="100" height="100" />" class="profile" alt="<perch:blog id="authorGivenName" /> <perch:blog id="authorFamilyName" />" /> </div> <h3> <perch:blog id="authorGivenName" type="text" default="name" label="Name" order="9"/> <perch:blog id="authorFamilyName" type="text" label="family name" order="10"/> </h3> <p class="staff-job-title"> <perch:blog id="staff_position" type="text" label="position" order="11"/> </p> <a target="_blank" href="mailto:<perch:blog id="authorEmail" default="email" type="text" label="email" order="12" />" target="_blank" class="staff-email"/> </a> <p class="staff-tel-no"> <perch:blog id="staff_telephone" type="text" label="Phone Number" order="13"/> </p> <p class=""> <perch:if exists="staff_linkedin"> <a class="linked staff_list" target="_blank" href="<perch:blog id="staff_linkedin" type="hidden" label="linkedin" order="14"/>"> Linkedin </a> <perch:if id="authorPostCount" match="gte" value="1"> <span> | </span><a class="article-link staff_list" href="archive.php?author=<perch:blog id="authorSlug" type="hidden" label="Articles" order="15"/>"> Articles (<perch:blog id="authorPostCount" label="postcount" order="25" type="hidden" />) </a></perch:if> <perch:else /> <perch:if id="authorPostCount" match="gte" value="1"> <a class="article-link staff_list" href="archive.php?author=<perch:blog id="authorSlug" type="hidden" label="Articles" order="16" />"> Articles (<perch:blog id="authorPostCount" label="postcount" order="25" type="hidden" />) </a></perch:if> </perch:if></p> </div> </perch:if> <p class="date-stamp">Posted on <perch:blog id="postDateTime" type="date" time="true" format="d F Y, H:i" label="Post date" order="40"/></p> <h4 class="share_story">Share this story</h4> <span class='st_facebook_large' displayText='Facebook'></span> <span class='st_twitter_large' displayText='Tweet'></span> <span class='st_linkedin_large' displayText='LinkedIn'></span> <span class='st_pinterest_large' displayText='Pinterest'></span> <span class='st_email_large' displayText='Email'></span> <perch:blog id="seo_description" type="text" label="Intro / Seo description" help="Describe the post using as many keywords as possible but in human readable sentences" suppress="true" order="18" /> <perch:if exists="related_post_title_1"> <h4 class="also_interested">You may also be interested in reading:</h4> <a href="<perch:blog id="related_post_url_1" type="text" label="URL 1" order="25"/>"> <perch:blog id="related_post_title_1" type="text" label="Tite 1" order="24" divider-before="Add links to related articles - Maximum of 4. If linking to external web page, please include https:// before the URL."/> </a> <br/><br/> </perch:if> <perch:if exists="related_post_title_2"> <a href="<perch:blog id="related_post_url_2" type="text" label="URL 2" order="27"/>"> <perch:blog id="related_post_title_2" type="text" label="Title 2" order="26"/> </a> <br/><br/> <perch:else /> </perch:if> <perch:if exists="related_post_title_3"> <a href="<perch:blog id="related_post_url_3" type="text" label="Url 3" order="29"/>"> <perch:blog id="related_post_title_3" type="text" label="Article 3" order="28"/> </a> <br/><br/> <perch:else /> </perch:if> <perch:if exists="related_post_title_4"> <a href="<perch:blog id="related_post_url_4" type="text" label="URL 4" order="31"/>"> <perch:blog id="related_post_title_4" type="text" label="Title 4" order="30"/> </a> <br/><br/> <perch:else /> </perch:if> <perch:template path="blog/posts/chunks/categories-tag.html" /> </article> </div> <perch:template path="blog/posts/chunks/post-back-button.html" /> </div> </div> </div> <?php include('_includes/search-area.php'); ?> </div> --- Our listings template: --- <perch:before> <ul class="hfeed listing"></perch:before> <li class="hentry"> <h2><a href="<perch:blog id="postURL" />" rel="bookmark" class="entry-title"><perch:blog id="postTitle" /></a></h2> <perch:if exists="image"><img src="<perch:blog id="image" type="image" width="50" height="50" crop="true" />" alt="<perch:blog id="postTitle" />" /></perch:if> <p class="entry-published date"><perch:blog id="postDateTime" type="date" time="true" format="d F Y, H:i" label="Post date" order="40"/></p> <div class="description entry-summary"> <perch:blog id="excerpt" type="textarea" textile="true" /> </div> </li> <perch:after> </ul> </perch:after> --- Our diagnostic report summary : --- Perch: 2.8.7, PHP: 5.5.21, MySQL: 5.1.73, with PDO Server OS: Linux, cgi-fcgi Installed apps: content (2.8.7), assets (2.8.7), categories (2.8.7), perch_blog (4.6), perch_forms (1.8.2), perch_backup (1.2) App runtimes: <?php include(PERCH_PATH.'/core/apps/content/runtime.php'); include(PERCH_PATH.'/core/apps/categories/runtime.php'); include(PERCH_PATH.'/addons/apps/perch_blog/runtime.php'); include(PERCH_PATH.'/addons/apps/perch_forms/runtime.php'); ?> PERCH_LOGINPATH: /perch PERCH_PATH: /nfs/c06/h05/mnt/185443/domains/connectcommunications.co.uk/html/perch PERCH_CORE: /nfs/c06/h05/mnt/185443/domains/connectcommunications.co.uk/html/perch/core PERCH_RESFILEPATH: /nfs/c06/h05/mnt/185443/domains/connectcommunications.co.uk/html/perch/resources Image manipulation: GD PHP limits: Max upload 2M, Max POST 20M, Memory: 99M, Total max file upload: 2M Resource folder writeable: Yes HTTP_HOST: www.connectcommunications.co.uk DOCUMENT_ROOT: /home/185443/domains/connectcommunications.co.uk/html REQUEST_URI: /perch/core/settings/diagnostics/ SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
Paul McGinnity

Paul McGinnity 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Can you try removing native="false" ?

Hi Drew, that didn't work

Drew McLellan

Drew McLellan 2638 points
Perch Support

Does the date field display on your edit form?

It does, it also outputs the correct date on the front end. https://www.connectcommunications.co.uk/whats-new

Drew McLellan

Drew McLellan 2638 points
Perch Support

So it's just the slug that is wrong?

I think so.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Can you turn debug on and show me what it outputs when you create a post?

Here you go Drew

Debug Message
SELECT u.*, r.* FROM perch2_users u, perch2_user_roles r WHERE u.roleID=r.roleID AND u.userEnabled=1 AND u.userID=1 AND u.userHash='584fea8a802aab53e6b776446912ee4d' LIMIT 1
UPDATE perch2_users SET userHash='e4688dc3c892a383e6c984aa57cf3687' WHERE userID=1
SELECT p.privKey FROM perch2_user_privileges p
SELECT * FROM (SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=1 OR userID=0 ORDER BY userID DESC) AS settings GROUP BY settingID
SELECT * FROM perch2_blog_authors WHERE authorEmail='webdev@connectcommunications.co.uk' LIMIT 1
SELECT * FROM perch2_blog_sections ORDER BY sectionTitle ASC
Using template: /templates/blog/post.html
Using sub-template: /templates/blog/posts/chunks/team-tag.html
Using sub-template: /templates/blog/posts/chunks/sector-tag.html
Using sub-template: /templates/blog/posts/chunks/industry-tag.html
SELECT COUNT(*) FROM perch2_blog_comments WHERE commentStatus='PENDING'
SELECT * FROM perch2_blog_authors ORDER BY authorFamilyName, authorGivenName ASC
Queries: 9
Memory: 2.3895
Drew McLellan

Drew McLellan 2638 points
Perch Support

Hmm, thanks. Creating a new post then redirects you to edit mode, so we don't actually get to see the debug, of course.

Do you get any errors in your server error log?

Hi Drew, I'm not seeing anything in the server error log (it's currently blank which I'm raising with the host). But I tried saving a test article with our news template, and then changing it to the blog (faulty) template and get this diagnostic report

Debug Message
SELECT u.*, r.* FROM perch2_users u, perch2_user_roles r WHERE u.roleID=r.roleID AND u.userEnabled=1 AND u.userID=1 AND u.userHash='91e50e30cda466d24a7d2ed3bc2fd44b' LIMIT 1
UPDATE perch2_users SET userHash='ed7f25514ad7332d458ef6d1ea09d4c2' WHERE userID=1
SELECT p.privKey FROM perch2_user_privileges p
SELECT * FROM (SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=1 OR userID=0 ORDER BY userID DESC) AS settings GROUP BY settingID
SELECT * FROM perch2_blog_authors WHERE authorEmail='webdev@connectcommunications.co.uk' LIMIT 1
SELECT * FROM perch2_blog_sections ORDER BY sectionTitle ASC
SELECT * FROM perch2_blog_posts WHERE postID=133
SELECT * FROM perch2_blog_sections ORDER BY sectionTitle ASC
Using template: /templates/blog/posts/blog.html
Using sub-template: /templates/blog/posts/chunks/categories-tag.html
Using sub-template: /templates/blog/posts/chunks/post-back-button.html
SELECT COUNT(*) FROM perch2_blog_comments WHERE commentStatus='PENDING'
SELECT * FROM perch2_categories c, perch2_category_sets s WHERE c.setID=s.setID AND s.setSlug='blog' ORDER BY catTreePosition ASC
Adding:
SELECT * FROM perch2_blog_authors ORDER BY authorFamilyName, authorGivenName ASC
Queries: 12
Memory: 2.4206
Array
(
    [type] => 2
    [message] => htmlspecialchars() expects parameter 1 to be string, array given
    [file] => /nfs/c06/h05/mnt/185443/domains/connectcommunications.co.uk/html/perch/core/lib/PerchUtil.class.php
    [line] => 137
)

Hi Drew, by removing the part of the post template that output the author contact details, I managed to get the Blog posts to display again, but I'm still getting an issue with the slug displaying as /2015-2015-06-01-01-test-post have you seen this issue before?

Also has the way Blog Author details are output changed in a recent update?

Paul.

Drew McLellan

Drew McLellan 2638 points
Perch Support

What do you have your slug format set to in Settings?

Meant to include this in the last post, sorry. The slug is formatted as: %Y-%F-%d-{postTitle}

UPDATE: I've changed the format to %Y-%m-%d-{postTitle}, which makes it output properly

Drew McLellan

Drew McLellan 2638 points
Perch Support

That simple?

Seems to be Drew! Thanks for all your help.