Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Changing COMMENTS date


Go to End
Reply


9 Posts   4301 Views

Avatar
Naely

Community Member, 4 Posts

4 January 2008 at 3:05am

I've discovered how to customize the date for posted news articles on my site, however I'm having trouble figuring out how to change the date format for posted Comments. Any input?

Avatar
Tobbe

Community Member, 25 Posts

4 January 2008 at 4:15am

Edited: 04/01/2008 4:16am

Sorry. Post deleted.
I answered a completely different question.

Avatar
Naely

Community Member, 4 Posts

4 January 2008 at 6:43am

What?

Avatar
Naely

Community Member, 4 Posts

4 January 2008 at 6:47am

oops, I understand :) thanks.

Avatar
areikiera

Community Member, 26 Posts

27 February 2008 at 5:25am

Make sure you've changed the date formats in:

sapphire\core\model\fieldtypes\Date.php
sapphire\core\model\fieldtypes\Datetime.php
AND
sapphire\core\model\fieldtypes\SSDatetime.php

I forgot to change the formats in the last one, and that's the one the Comments section uses.

Avatar
Willr

Forum Moderator, 5513 Posts

27 February 2008 at 9:32am

you can also customize how it displays like '12 Feb 2008' or '2 days ago' but making a custom template for the page comments in your theme.

If you open cms / templates / PageCommentInterface_singlecomment.ss you can see that that is the html for each comment and if you would like to change the overall format of the date you can edit that file. A better idea though, is to copy that file to themes / yourtheme / templates / Includes / and edit it there. Ideally you don't want to edit anything in cms or sapphire as this will make it hard for you to upgrade in the future.

Avatar
dewoob

Community Member, 10 Posts

31 August 2008 at 12:02am

Edited: 31/08/2008 12:31am

For German dates, the Date.Ago function would need to place the word 'vor', the translation of 'ago', *in front of* the timespan, because it says "vor 20 Minuten" in German.

The _t function needs to be extended to support placeholders. So you could call the _t function with the timespan as a named parameter (was that the idea behind the not-used $context argument?).

Example:

Core.php:
function _t( $entity, $string = "", $priority = 40, $context = "", $values = array() ) {
// at the end, replace every placeholder in $transEntity by its corresponding value
}

Date.php:
_t( "Date.AGO", " ago", PR_MEDIUM, "", array( 'TIMESPAN' => $this->TimeDiff() ) );

de_DE.php:
$lang['de_DE']['Date']['AGO'] = 'vor {TIMESPAN}';

I'm new to silverstripe, so I don't dare to mess around in the core... but I will try this out in my local installation. :-)

---

I just tried it out, works fine.

function _t($entity, $string = "", $priority = 40, $context = "", $values = array() ) {
   global $lang;
   $locale = i18n::get_locale();
   $entityParts = explode('.',$entity);
   $realEntity = array_pop($entityParts);
   $class = implode('.',$entityParts);
   if(!isset($lang[$locale][$class])) i18n::include_by_class($class);
   $transEntity = isset($lang[i18n::get_locale()][$class][$realEntity]) ? $lang[i18n::get_locale()][$class][$realEntity] : $string;
   $result = (is_array($transEntity) ? $transEntity[0] : $transEntity);
foreach( $values as $key => $value ) {
$result = str_replace( '{' . strtoupper( $key ) . '}', $value, $result );
}
return $result;
}

Avatar
Knastinnot

Community Member, 1 Post

11 September 2008 at 11:39pm

Hi,

i'm new to SS, and have a problem.

For some reason, my SS-Installation won't let me override the SSDatetime-Class.
Using
Object::useCustomClass("SSDatetime", "CustomSSDatetime");
in the _config.php won't do anything.

Does anyone know why?

Thanks in advanced.

Go to Top