Search
Other ReReplacer questions
Forum

Multiple PHP replacements

Jurgen Gaeremyn's Avatar Jurgen Gaeremyn
Hi,

I'm probably doing something stupidly wrong here, but I can't seem to find it.
I created 3 PHP scriptlets that replace a moustache string with a date.

Yet, for some reason {NEXTDFD} renders the date for {NEXTHFD}
Could you have a quick look? Thanks!

Here is the export of my rereplace elements:
[{"name":"Next SFD","description":"Replace {NEXTSFD} by the date of the next SFD","category":"DATES","search":"{NEXTSFD}","replace":"<?php\r\n$year = date('Y');\r\n$sfd = new DateTime(\"third saturday of september $year\");\r\n\r\n    \/\/ If the date has already passed in the current year, get the date for the next year\r\n    if ($sfd < new DateTime()) {\r\n        $year += 1;\r\n        $sfd = new DateTime(\"third saturday of september $year\");\r\n    }\r\n\r\n    echo $sfd->format('l, F jS Y');\r\n?>","area":"body","params":"{\"xml\":\"\",\"use_xml\":\"0\",\"regex\":\"0\",\"treat_as_list\":\"0\",\"word_search\":\"0\",\"s_modifier\":\"1\",\"casesensitive\":\"0\",\"max_replacements\":\"\",\"thorough\":\"0\",\"strip_p_tags\":\"0\",\"treat_as_php\":\"1\",\"enable_in_category\":\"1\",\"enable_in_title\":\"1\",\"enable_in_author\":\"1\",\"enable_in_feeds\":\"1\",\"enable_in_admin\":\"0\",\"enable_in_edit_forms\":\"0\",\"between_start\":\"\",\"between_end\":\"\",\"enable_tags\":\"1\",\"limit_tagselect\":\"0\",\"tagselect\":\"*[title,alt]_meta[content]\",\"has_conditions\":\"0\",\"condition_id\":\"\",\"condition_alias\":\"\",\"condition_name\":\"\",\"other_doreplace\":\"0\",\"other_replace\":\"\"}","published":1,"ordering":0},{"name":"Next HFD","description":"Replace {NEXTHFD} by the date of the next HFD","category":"DATES","search":"{NEXTHFD}","replace":"<?php\r\n$year = date('Y');\r\n$hfd = new DateTime(\"third saturday of april $year\");\r\n\r\n\/\/ If the date has already passed in the current year, get the date for the next year\r\n\r\nif ($hfd < new DateTime()) {\r\n  $year += 1;\r\n  $hfd = new DateTime(\"third saturday of april $year\");\r\n  }\r\necho $hfd->format('l, F jS Y');\r\n?>","area":"body","params":"{\"xml\":\"\",\"use_xml\":\"0\",\"regex\":\"0\",\"treat_as_list\":\"0\",\"word_search\":\"1\",\"s_modifier\":\"1\",\"casesensitive\":\"0\",\"max_replacements\":\"\",\"thorough\":\"0\",\"strip_p_tags\":\"0\",\"treat_as_php\":\"1\",\"enable_in_category\":\"1\",\"enable_in_title\":\"1\",\"enable_in_author\":\"1\",\"enable_in_feeds\":\"1\",\"enable_in_admin\":\"0\",\"enable_in_edit_forms\":\"0\",\"between_start\":\"\",\"between_end\":\"\",\"enable_tags\":\"1\",\"limit_tagselect\":\"0\",\"tagselect\":\"*[title,alt]_meta[content]\",\"has_conditions\":\"0\",\"condition_id\":\"\",\"condition_alias\":\"\",\"condition_name\":\"\",\"other_doreplace\":\"0\",\"other_replace\":\"\"}","published":1,"ordering":0},{"name":"Next DFD","description":"Replace {NEXTDFD} by the date of the next DFD","category":"DATES","search":"{NEXTDFD}","replace":"<?php\r\n$year = date('Y');\r\n$dfd = new DateTime(\"last wednesday of march $year\");\r\n\r\n    \/\/ If the date has already passed in the current year, get the date for the next year\r\n    if ($hfd < new DateTime()) {\r\n        $year += 1;\r\n        $hfd = new DateTime(\"last wednesday of march $year\");\r\n    }\r\n\r\n    echo $hfd->format('l, F jS Y');\r\n?>","area":"body","params":"{\"xml\":\"\",\"use_xml\":\"0\",\"regex\":\"0\",\"treat_as_list\":\"0\",\"word_search\":\"0\",\"s_modifier\":\"1\",\"casesensitive\":\"0\",\"max_replacements\":\"\",\"thorough\":\"0\",\"strip_p_tags\":\"0\",\"treat_as_php\":\"1\",\"enable_in_category\":\"1\",\"enable_in_title\":\"1\",\"enable_in_author\":\"1\",\"enable_in_feeds\":\"1\",\"enable_in_admin\":\"0\",\"enable_in_edit_forms\":\"0\",\"between_start\":\"\",\"between_end\":\"\",\"enable_tags\":\"1\",\"limit_tagselect\":\"0\",\"tagselect\":\"*[title,alt]_meta[content]\",\"has_conditions\":\"0\",\"condition_id\":\"\",\"condition_alias\":\"\",\"condition_name\":\"\",\"other_doreplace\":\"0\",\"other_replace\":\"\"}","published":1,"ordering":0}]

URL: digitalfreedoms.org
Peter van Westen's Avatar Peter van Westen ADMIN
For some reason you have Word Search on in the NEXTHFD replacement. Switch that off.
Please post a rating at the Joomla! Extensions Directory
Jurgen Gaeremyn's Avatar Jurgen Gaeremyn
I turned it off.
I cleared cache.
Still showing the wrong date.
Jurgen Gaeremyn's Avatar Jurgen Gaeremyn
Never mind... apparently I didn't save the instance when I changed the variable name in DFD. (it still used $hfd instead of $dfd for the output)
Sorry for bothering.
You can only post on the extension support forum if you have an active subscription and you log in

Buy a Pro subscription