Not Solved PHP in Templates and Template Conditionals
Not Solved
(2023-02-02, 01:14 PM)HLFadmin Wrote: Has anyone found the fix for using this plugin with PHP 8? Getting this error.

Warning [2] Undefined array key 2 - Line: 92 - File: inc/plugins/phptpl.php PHP 8.0.27 (Linux)
[...]
using a simple conditional in forumdisplay_threadlist template
					<if $foruminfo["fid"] == "115" then>
							&emsp;<a href="https://www.worldcommunitygrid.org/team/viewTeamMemberDetail.do?sort=name&teamId=xxxxxxxxxx" target="_blank">click for Team stats.</a>
							</if>

It looks to me that the problem is that the regular expression on line 91 can match only "</if>", in which case the matches array $m will include entries only at index zero (</if>) and one (/if), and no entry will be set for index two. Without testing, it looks as though the fix, then, is to change line 192 from:
				return phptpl_if($m[1], phptpl_unescape_string($m[2]));
to:
				return phptpl_if($m[1], phptpl_unescape_string(isset($m[2]) ? $m[2] : ''));

An empty second parameter to phptpl__if() is fine in this scenario because it only uses the first for /ifs.
Reply


Messages In This Thread
RE: PHP in Templates and Template Conditionals - by Laird - 2023-02-03, 08:33 AM
RE: Template conditionals - by expat - 2015-01-31, 05:28 AM

Forum Jump:


Users browsing this thread: 6 Guest(s)