[Solved]CGBlog date format

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
jasnick
Power Poster
Power Poster
Posts: 695
Joined: Sat Jan 15, 2011 8:36 am
Location: Western Australia

[Solved]CGBlog date format

Post 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
Last edited by jasnick on Thu Mar 07, 2013 12:01 am, edited 1 time in total.
User avatar
paulbaker
Dev Team Member
Dev Team Member
Posts: 1465
Joined: Sat Apr 18, 2009 10:09 pm
Location: Maidenhead, UK
Contact:

Re: CGBlog date format

Post by paulbaker »

Change your code snippet to simply:

Code: Select all

{$postdate|cms_date_format}/{$title}
jasnick
Power Poster
Power Poster
Posts: 695
Joined: Sat Jan 15, 2011 8:36 am
Location: Western Australia

Re: CGBlog date format

Post 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
User avatar
paulbaker
Dev Team Member
Dev Team Member
Posts: 1465
Joined: Sat Apr 18, 2009 10:09 pm
Location: Maidenhead, UK
Contact:

Re: CGBlog date format

Post 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?
jasnick
Power Poster
Power Poster
Posts: 695
Joined: Sat Jan 15, 2011 8:36 am
Location: Western Australia

Re: CGBlog date format

Post 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!
User avatar
paulbaker
Dev Team Member
Dev Team Member
Posts: 1465
Joined: Sat Apr 18, 2009 10:09 pm
Location: Maidenhead, UK
Contact:

Re: CGBlog date format

Post 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.
jasnick
Power Poster
Power Poster
Posts: 695
Joined: Sat Jan 15, 2011 8:36 am
Location: Western Australia

Re: CGBlog date format

Post 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
User avatar
paulbaker
Dev Team Member
Dev Team Member
Posts: 1465
Joined: Sat Apr 18, 2009 10:09 pm
Location: Maidenhead, UK
Contact:

Re: CGBlog date format

Post by paulbaker »

That's the Summary Template then.
jasnick
Power Poster
Power Poster
Posts: 695
Joined: Sat Jan 15, 2011 8:36 am
Location: Western Australia

Re: CGBlog date format

Post by jasnick »

This is in the Summary template:


{if $entry->postdate}
<div class="CGBlogSummaryPostdate">
{$entry->postdate|cms_date_format}
</div>
{/if}
User avatar
paulbaker
Dev Team Member
Dev Team Member
Posts: 1465
Joined: Sat Apr 18, 2009 10:09 pm
Location: Maidenhead, UK
Contact:

Re: CGBlog date format

Post 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).
jasnick
Power Poster
Power Poster
Posts: 695
Joined: Sat Jan 15, 2011 8:36 am
Location: Western Australia

Re: CGBlog date format

Post 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 -->
User avatar
paulbaker
Dev Team Member
Dev Team Member
Posts: 1465
Joined: Sat Apr 18, 2009 10:09 pm
Location: Maidenhead, UK
Contact:

Re: CGBlog date format

Post 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? ???
jasnick
Power Poster
Power Poster
Posts: 695
Joined: Sat Jan 15, 2011 8:36 am
Location: Western Australia

Re: CGBlog date format

Post 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.
Attachments
cgblog.png
cgblog.png (5.77 KiB) Viewed 2222 times
User avatar
paulbaker
Dev Team Member
Dev Team Member
Posts: 1465
Joined: Sat Apr 18, 2009 10:09 pm
Location: Maidenhead, UK
Contact:

Re: CGBlog date format

Post 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.
jasnick
Power Poster
Power Poster
Posts: 695
Joined: Sat Jan 15, 2011 8:36 am
Location: Western Australia

Re: CGBlog date format

Post 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
Post Reply

Return to “Modules/Add-Ons”