Please read and follow the COMMON ISSUES first!
Always add your version information in every new post! Thank you!

Form2Content Forum

Questions and answers for Form2Content, a Joomla CCK.
  1. Ihvar
  2. Form2Content Lite & Pro
  3. Sunday, 10 November 2019
  4.  Subscribe via email
Hi!
I'm trying to change months names inside template, but $the_date is empty and nothing happens


{php}

setlocale(LC_ALL, 'ru_RU.UTF-8');

$the_date = $template->tpl_vars['ACTION_DATE_START_RAW']->value;

$the_date = date_format($template->tpl_vars['ACTION_DATE_START_RAW']->value, "%d %B %Y");


$replacements = array( "Январь" => "января", "Февраль" => "февраля", "Март" => "марта", "Апрель" => "апреля", "Май" => "мая", "Июнь" => "июня", "Июль" => "июля", "Август" => "августа", "Сентябрь" => "сентября", "Октябрь" => "октября", "Ноябрь" => "ноября", "Декабрь" => "декабря" );

echo strtr($the_date, $replacements);

{/php}

Responses (3)
Accepted Answer Pending Moderation
Hi Ihvar,

Have you tried this method: https://documentation.form2content.com/f2c-field-types/date-select-field

Regards,
Patrick
Please read the F2C documentation before asking questions! Thank you if you've done so ;)
Accepted Answer Pending Moderation
Hi Ihvar,

Have you tried this method: https://documentation.form2content.com/f2c-field-types/date-select-field

Regards,
Patrick


Hi, F2C webmaster!
I've tried it, but I want to change months' names, so I need my {$ACTION_DATE_START_RAW|date_format:"%d %B %Y"} to be processed by

$replacements = array( "Январь" => "января", "Февраль" => "февраля", "Март" => "марта", "Апрель" => "апреля", "Май" => "мая", "Июнь" => "июня", "Июль" => "июля", "Август" => "августа", "Сентябрь" => "сентября", "Октябрь" => "октября", "Ноябрь" => "ноября", "Декабрь" => "декабря" );


to echo result in template


echo strtr($the_date, $replacements);


What the syntax to use method you've mensioned inside {php} tag?

This code leads to "error: Internal Server Error":


$the_date = {$ACTION_DATE_START_RAW|date_format:"%d %B %Y"};
Accepted Answer Pending Moderation
I've found the solution


$the_date = $template->tpl_vars['ACTION_DATE_START']->value;
$formatter = new IntlDateFormatter('ru_RU', IntlDateFormatter::FULL, IntlDateFormatter::FULL);
$formatter->setPattern('d MMMM');
echo $formatter->format(new DateTime($the_date));
  • Page :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.