Closed Fraenkiman closed 2 years ago
Not as simple as it seems: Month names are generated by Smarty automatically...
fp-interface/sharedtpls/search.tpl:
<p>{html_select_date month_names=$monthnames start_year=2000 end_year=$smarty.now|date_format:"%Y" field_separator=" - " field_order="DMY" time="0000-00-00" all_empty="--"}</p>
Hello, everyone,
laborix has created a possible solution in this forum post. Perhaps one can accommodate the PHP8.1 compatible with. However, I haven't had a chance to test the solution yet
Best Regards
Hello, everyone,
laborix from our FlatPress forum created a working solution in the post.
The Smarty module function.html_select_date.php must be adjusted as follows:
Replace the lines 190 - 193 in the file "/fp-includes/smarty/plugins/function.html_select_date.php"
for ($i = 1; $i <= 12; $i++) {
$month_names[$i] = strftime($month_format, mktime(0, 0, 0, $i, 1, 2000));
$month_values[$i] = strftime($month_value_format, mktime(0, 0, 0, $i, 1, 2000));
}
with this code:
/*
* Flatpress issue #132
* Months are displayed in the wrong language in the search
*
* Debug: 2022-09-27
* Using now the month_names from the Flatpress language files
*/
global $lang;
$replace_month_names = array();
$replace_month_names[0] = '-';
$replace_month_value_format = array("00","01","02","03","04","05","06","07","08","09","10","11","12");
$fp_lang_months = array();
$fp_lang_months = $lang['date']['month'];
$fplm = 0;
for ($lm = 1; $lm <= 12; $lm++) {
$replace_month_names[$lm] = $fp_lang_months[$fplm];
$fplm++;
}
for ($i = 1; $i <= 12; $i++) {
$month_names[$i] = $replace_month_names[$i];
$month_values[$i] = $replace_month_value_format[$i];
}
The correct search results should now appear (tested with FlatPress 1.2.1 under PHP 8.0) and run under PHP 7.x, as well as PHP 8.0 and PHP 8.1.
I also tested the solution using FlatPress fp-1.3.dev [master] - and it works very well, as expected.
Best regards and have a restful night
Hello, everyone,
in the search (search.php) when selecting the month instead of the selected default language; in my case German, the month is displayed in English.
Best Regards