Page 1 of 2

[Solved]CGBlog date format

Posted: Wed Feb 27, 2013 1:07 am
by jasnick
Using 1.11.4. and up to date modules

I want to change the date format for CGBlog to the same as in Global Settings: %d/%m/%y.

In Options/Url Template:
{$postdate|cms_date_format:'%Y'}/{$postdate|cms_date_format:'%m'}/{$title}

I've tried various changes to no avail. I read that if it was not specified in CGBlog, it would use the setting in Global Settings.

So how do I "unspecify" it or change it so that my date format is used in the Admin/CGBlog/Entries?

Thanks

Re: CGBlog date format

Posted: Tue Mar 05, 2013 12:42 am
by paulbaker
Change your code snippet to simply:

Code: Select all

{$postdate|cms_date_format}/{$title}

Re: CGBlog date format

Posted: Tue Mar 05, 2013 1:18 am
by jasnick
Hi Paul

Thanks for that: I changed it but it hasn't made any difference. Date in the list of articles is still showing month number first, instead of day number first. [I am talking about the list of entries that shows under the Entries tab. I have cleared cache.]

For example: an article posted on 5th of March 2013 now shows as 3/5/2013. I want it to show as 5/3/2013. This is the same for all lists, date posted, start date and finish date.

I am wondering if it is the Archive List template I should be changing?

{* archive template *}
{if isset($archivelist)}
<ul>
{foreach from=$archivelist item=one}
<li><a href="{$one.summary_url}">{$one.datestamp|date_format:"%B"} {$one.datestamp|date_format:"%Y"} - ({$one.count})</a></li>
{/foreach}
</ul>
{/if}

Thanks

Re: CGBlog date format

Posted: Tue Mar 05, 2013 1:45 am
by paulbaker
Sounds like you are editing the wrong template to me. Quite easy to do when there's so many. Put a quick text marker in there like "BOO!" and save the template - then refresh the live site. That'll soon tell you if you're fiddling with the right one. (Remember to take away the marker afterwards. :D )

What do you have in Global Settings -> General Settings tab -> Date Format String?

Re: CGBlog date format

Posted: Tue Mar 05, 2013 2:14 am
by jasnick
Hi Paul

Global settings is %d/%m/%y

I had a quick look before at all the templates and the only one that has other than what you suggested in the first reply is this archive one.

Which is the template that applies to the Entries tab page?

Thanks!

Re: CGBlog date format

Posted: Tue Mar 05, 2013 3:48 pm
by paulbaker
Summary Templates are normally used to show the first few words of a whole lot of posts. Detail Templates are used to display the whole of one post.

Re: CGBlog date format

Posted: Tue Mar 05, 2013 11:19 pm
by jasnick
Hi Paul

I don't mean the pages where one adds the articles, I mean the list of articles that is the landing page for the CGBlog - the first page one sees when opening it.

Thanks

Re: CGBlog date format

Posted: Tue Mar 05, 2013 11:36 pm
by paulbaker
That's the Summary Template then.

Re: CGBlog date format

Posted: Tue Mar 05, 2013 11:41 pm
by jasnick
This is in the Summary template:


{if $entry->postdate}
<div class="CGBlogSummaryPostdate">
{$entry->postdate|cms_date_format}
</div>
{/if}

Re: CGBlog date format

Posted: Wed Mar 06, 2013 12:49 am
by paulbaker
Well that looks OK to me and I have just tried that code in one of my sites. It worked as expected. If I change the format of Date Format String, CGBlog respects the change and shows the date appropriately.

Maybe post your entire Summary Template? Also what version of CGBlog are you using? My test was on CMSMS 1.10.3 and CGBlog 1.8.3 (not latest).

Re: CGBlog date format

Posted: Wed Mar 06, 2013 12:58 am
by jasnick
CMSMS 1.11.4 CGBlog 1.9.12

This is the sample Summary template. Thanks

<!-- Start CGBlog Display Template -->
{if isset($error)}{cgerror}{$error}{/cgerror}{/if}

{if $pagecount > 1}
<p>
{if $pagenumber > 1}
{$firstpage} {$prevpage}
{/if}
{$pagetext} {$pagenumber} {$oftext} {$pagecount}
{if $pagenumber < $pagecount}
{$nextpage} {$lastpage}
{/if}
</p>
{/if}
{foreach from=$items item=entry}
<div class="CGBlogSummary">

{if $entry->postdate}
<div class="CGBlogSummaryPostdate">
{$entry->postdate|cms_date_format}
</div>
{/if}

<div class="CGBlogSummaryLink">
<a href="{$entry->detail_url}" title="{$entry->title|escape:htmlall}">{$entry->title|escape}</a>
</div>





{if $entry->summary}
<div class="CGBlogSummarySummary">
{eval var=$entry->summary}
</div>

{else if $entry->content}

<div class="CGBlogSummaryContent">
{eval var=$entry->content}
</div>
{/if}

{if isset($entry->extra)}
<div class="CGBlogSummaryExtra">
{eval var=$entry->extra}
{* {cms_module module='Uploads' mode='simpleurl' upload_id=$entry->extravalue} *}
</div>
{/if}
{if isset($entry->fields)}
{foreach from=$entry->fields item='field'}
<div class="CGBlogSummaryField">
{if $field->type == 'file'}
<img src="{$entry->file_location}/{$field->value}"/>
{else}
{$field->name}: {eval var=$field->value}
{/if}
</div>
{/foreach}
{/if}

</div>
{/foreach}
<!-- End CGBlog Display Template -->

Re: CGBlog date format

Posted: Wed Mar 06, 2013 1:12 am
by paulbaker
That looks OK to me. So to summarise your issue: You change the Date Format String and CGBlog seems to ignore this and show the date in its own way? If that's the issue then you've done everything I would do and I don't understand why it's not working.

Maybe someone else can chime in here? ???

Re: CGBlog date format

Posted: Wed Mar 06, 2013 3:53 am
by jasnick
Yes Paul - that's it. Thanks!

Site Admin/Global Settings/Date Format String: %d/%m/%y

CGBlog/Options/Url Template: {$postdate|cms_date_format}/{$title}

Summary template contains:
{if $entry->postdate}
<div class="CGBlogSummaryPostdate">
{$entry->postdate|cms_date_format}
</div>
{/if}

Main page of editing section of CGBlog (Entries):see pic. For example, Post Date should be 6th day of the 3rd month, 2013 - not 3rd day of the 6th month.

Re: CGBlog date format

Posted: Wed Mar 06, 2013 9:36 am
by paulbaker
Ah. I believe there is a misunderstanding here. The templates we are discussing control the display of the front end - the bit website visitors see. You have posted a screen shot of the back end. AFAIK the Date Format String doesn't change the display of the back end.

To change this layout you should be able use the methods discussed here:
http://forum.cmsmadesimple.org/viewtopi ... =4&t=64063

I do something similar to CGCalendar so it displays dates in a nicer (UK) format in the back end.

Re: CGBlog date format

Posted: Thu Mar 07, 2013 12:00 am
by jasnick
Hi Paul

YES! I remember now I had a similar issue a fair while ago with FEU and SelfReg and remember making a module_custom for that site.

My memory is not what it was!!!

Thank you very much for the help. It does annoy me in the back end to see the dates in a format that could be easily misconstrued by an editor as we don't use that system for dates. At least it is OK on the front end. ;D