17488 Posts in 4473 Topics by 1978 members
| Go to End | Next > | |
| Author | Topic: | 3848 Views |
-
Changing COMMENTS date

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?
-
Re: Changing COMMENTS date

4 January 2008 at 4:15am Last edited: 4 January 2008 4:16am
Sorry. Post deleted.
I answered a completely different question. -
Re: Changing COMMENTS date

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.phpI forgot to change the formats in the last one, and that's the one the Comments section uses.
-
Re: Changing COMMENTS date

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.
-
Re: Changing COMMENTS date

31 August 2008 at 12:02am Last edited: 31 August 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;
} -
Re: Changing COMMENTS date

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.
| 3848 Views | ||
| Go to Top | Next > |




