Forum

Thread tagged as: Question, Problem, Blog

Blog Post Date

Hi there,

I am having a problem in which I can't edit the date that the post was published. Whenever I change the date and save the form it just ends up defaulting back to today's date and time. Is there something obvious that I am missing? I am guessing it is something simple but I can't see it :(

post.html template:

<div class="col-sm-3 blog-post-left">
    <div>
        <img class="post-feat-image" src="<perch:blog id="image" type="image" width="263" height="263" crop="true" label="Image" required="true" />" alt="<perch:blog id="postTitle" />">
        <p class="blog-post-meta"><i class="fa fa-calendar" aria-hidden="true"></i> <perch:blog id="postDateTime" type="date" time="true" format="M d, Y" type="hidden" /></p>
        <p class="blog-post-meta"><i class="fa fa-user" aria-hidden="true"></i> <perch:blog id="authorGivenName" type="hidden" /> <perch:blog id="authorFamilyName" type="hidden" /></p>
    </div>
</div>

<div class="col-sm-9 blog-post-right">
    <h1><perch:blog id="postTitle" type="text" label="Title" required="true" size="xl autowidth" order="1" /></h1>
    <perch:blog id="postDescHTML" type="textarea" label="Post" editor="markitup" markdown="true" size="xxl autowidth" required="true" />
</div>

<perch:blog id="excerpt" type="textarea" label="Excerpt" markdown="true" size="s" required="true" suppress="true" />
<perch:blog id="postDateTime" type="date" time="true" format="Y-m-d H:i:s" label="Date" suppress="true">
<perch:blog id="image" type="image" width="360" height="240" crop="true" suppress="true" />

Diagnostics:

Perch: 2.8.32, PHP: 7.0.12, MySQL: mysqlnd 5.0.12-dev - 20150407 - $Id: 241ae00989d1995ffcbbf63d579943635faf9972 $, with PDO
Server OS: Linux, cgi-fcgi
Installed apps: content (2.8.32), assets (2.8.32), categories (2.8.32), perch_blog (5.0), perch_gallery (2.8.6), perch_shop_orders (PERCH_SHOP_VERSION), perch_shop_products (1.0.9), perch_shop (1.0.9), perch_members (1.5)
App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_members', 'perch_shop', 'perch_blog', 'perch_gallery' ); ?>
PERCH_LOGINPATH: /perch
PERCH_PATH: /customers/e/a/0/aatelierengland.co.uk/httpd.www/perch
PERCH_CORE: /customers/e/a/0/aatelierengland.co.uk/httpd.www/perch/core
PERCH_RESFILEPATH: /customers/e/a/0/aatelierengland.co.uk/httpd.www/perch/resources
Image manipulation: GD
PHP limits: Max upload 96M, Max POST 96M, Memory: 536870912M, Total max file upload: 96M
F1: 2edba60ed1f613d6dd804feb202456a2
Resource folder writeable: Yes
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
REQUEST_URI: /perch/core/settings/diagnostics/
HTTP_HOST: www.aatelierengland.co.uk
DOCUMENT_ROOT: /customers/e/a/0/aatelierengland.co.uk/httpd.www

Thanks guys :)

Martin Murphy

Martin Murphy 0 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Looks like your tag is malformed:

<perch:blog id="postDateTime" type="date" time="true" format="Y-m-d H:i:s" label="Date" suppress="true">

Should be:

<perch:blog id="postDateTime" type="date" time="true" format="Y-m-d H:i:s" label="Date" suppress="true" />

Hi Drew, thanks for the reply. I have fixed that error in my code however still experiencing the issue as the dates still don't change on existing posts and can't set it on new posts. Just still keeps reverting back to current date / time.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Oh, here we go, there's another hidden higher up the template:

<perch:blog id="postDateTime" type="date" time="true" format="M d, Y" type="hidden" />

You can't set the type attribute twice. I think you need to remove type="hidden".

Right yes, I see now.

The idea here was that I wanted the date in the admin form to be at the bottom so the idea was to add the field at the bottom and hide the one at the top. Is there a better way to accomplish this? If that makes sense..

**EDIT - Just took the first date field out and tried to save the form again a few times and still changing the date to current time / date :(

Drew McLellan

Drew McLellan 2638 points
Perch Support

For editing, the first instance of each ID is used. So if you want to control that, add you tag at the start of the template and suppress it.

If you need to check if it's your template or something else, switch back to the default template and test.

Okay I have got the field working now which is great. So my template now looks like this:

<div class="col-sm-3 blog-post-left">
    <div>
        <img class="post-feat-image" src="<perch:blog id="image" type="image" width="263" height="263" crop="true" label="Image" required="true" />" alt="<perch:blog id="postTitle" />">
        <p class="blog-post-meta"><i class="fa fa-calendar" aria-hidden="true"></i> <perch:blog id="postDateTime" type="date" time="true" format="Y-m-d H:i:s" label="Date" /></p>
        <p class="blog-post-meta"><i class="fa fa-user" aria-hidden="true"></i> <perch:blog id="authorGivenName" type="hidden" /> <perch:blog id="authorFamilyName" type="hidden" /></p>
    </div>
</div>

<div class="col-sm-9 blog-post-right">
    <h1><perch:blog id="postTitle" type="text" label="Title" required="true" size="xl autowidth" order="1" /></h1>
    <perch:blog id="postDescHTML" type="textarea" label="Post" editor="markitup" markdown="true" size="xxl autowidth" required="true" />
</div>

<perch:blog id="excerpt" type="textarea" label="Excerpt" markdown="true" size="s" required="true" suppress="true" />
<perch:blog id="image" type="image" width="360" height="240" crop="true" suppress="true" />

So the less important part would be how would I edit that to get the editable field at the bottom of the form whilst still printing the date in the current place on the front end and using a different date format?

Thanks for your help Drew :)

Drew McLellan

Drew McLellan 2638 points
Perch Support

You can use the order attribute to set the order the fields appear in the edit form.