Hi,
where kann ich Change the Date Format in my HTML Newsltters. I don't wanna use the
d/m/Y Format (for example 15/3/2011) ... i wanna have looks like 15. March 2011
Can someone please help me??
Hi,
where kann ich Change the Date Format in my HTML Newsltters. I don't wanna use the
d/m/Y Format (for example 15/3/2011) ... i wanna have looks like 15. March 2011
Can someone please help me??
About [DATE] placeholder, it is filtered by gettetxt, so you can edit it in .po/.mo translation files in language folder. Open the file of your language and look for j / n / Y string.
Otherwise, you can add a function like the following that filters the placeholder before the standard plugin filter (note the priority - 3rd argument - set to 5):
function custom_easymail_edit_date ( $content, $newsletter, $recipient, $stop_recursive_the_content=false ) {
if ( !is_object( $recipient ) ) $recipient = new stdClass();
if ( empty( $recipient->lang ) ) $recipient->lang = alo_em_short_langcode ( get_locale() );
// In following line change 'j / n / Y' as you like!
$date = date_i18n( 'j / n / Y', strtotime( $newsletter->post_date ) );
$content = str_replace("[DATE]", $date, $content);
return $content;
}
add_filter ( 'alo_easymail_newsletter_content', 'custom_easymail_edit_date', 5, 4 );
(Not tested but it should work).
You can use this method to customise all standard placeholders before plugin replacement.
When using qTranslate you could also use the default time and date preference set for each language in the qTranslate settings menu:
global $q_config;
$myDateString = '';
if (function_exists( 'qtrans_strftime' )) { // check if the qTranslate plugin is active
$myDateString.= qtrans_strftime( $q_config['date_format'][ $recipient->lang ], strtotime( $newsletter->post_date ) );
$myDateString.= ' ' . __('[:en]at[:nl]om[:de]uhm'). ' ';
$myDateString.= qtrans_strftime( $q_config['time_format'][ $recipient->lang ], strtotime( $newsletter->post_date ) );
$myDateString.= __('[:en] o\'clock[:nl]u[:de] Uhr');
} else {
// use the blog's default date formatting or something else to your own liking
$myDateString.= date_i18n( get_option( 'date_format' ) . ' H:i', $newsletter->post_date );
}
$content = str_replace("[DATE]", $myDateString, $content);
etc.
This is not a complete function but I guess you'll get the idea.
(editted to remove some code left overs)
Hey Alo,
can I add that code to alo-easymail_custom-hooks.php file?
Or a different code?
I would love to change the date format in my themes as well.
Thanks so much for any help!
Hi, you can add the code in alo-easymail_custom-hooks.php, of course.
Thanks Alo,
I did try the code in alo-easymail_custom-hooks.php but nothing changed in the theme. The date still displayed as 01/01/11 instead of January, 1 2011
Please Alo, help me out with this.
I added the code just like its shown above to the alo-easymail_custom-hooks.php file and changed:
$date = date_i18n( 'j / n / Y',
For...
$date = date_i18n( 'F j, Y',
However the date on the Newsletter still shows:
23 / 8 / 2011
Try the following code:
function custom_easymail_edit_date_pre ( $content, $newsletter, $recipient, $stop_recursive_the_content=false ) {
$content = str_replace("[DATE]", "[DATE-CUSTOM]", $content);
return $content;
}
add_filter ( 'alo_easymail_newsletter_content', 'custom_easymail_edit_date_pre', 3, 4 );
function custom_easymail_edit_date_post ( $content, $newsletter, $recipient, $stop_recursive_the_content=false ) {
$date = date_i18n( 'F j, Y', strtotime( $newsletter->post_date ) );
$content = str_replace("[DATE-CUSTOM]", $date, $content);
return $content;
}
add_filter ( 'alo_easymail_newsletter_content', 'custom_easymail_edit_date_post', 20, 4 );
The issue is that the at lower priority the $content doesn't include the theme text yet, so you have to run your custom code at a higher value (eg. 20) but first (eg. priority 3) you need to rename the placeholder to avoid the standard filter. I hope it's clear and understandable... (sorry for my bad english...).
It should work... let us know. In next version I'll include an automatic theme translation.
Hey there Alo.
I added this new code and added [DATE-CUSTOM] to my Theme and it worked perfectly!
Thank you so much!!
I really appreciate this.
Perfect. With that code, the [DATE] placeholder should work in the same way of [DATE-CUSTOM].
You must log in to post.