Not Solved PHP in Templates and Template Conditionals
Not Solved
edit: Nvm, got it!
Reply
Not Solved
can't be it used for particular url ? like
<if a href="/index.php" then>
blaahhhh
<else>
hhhhaalb
</if>
Reply
Not Solved
<if constant('THIS_SCRIPT') == 'index.php' then>
	yay!
</if>
Reply
Not Solved
Is there a way to create an If else statement for member profiles, for example, if I am looking at my member profile, I will see "this", and if looking at someone else's member profile then I will see "that"


I've been trying, but can seem to get it.

any help?

<if $GLOBALS['mybb']->user['uid] then>looking at my member profile sees "this"<else> looking at someone else's profile sees "that"</if>

(2022-01-01, 05:41 AM)Michael2014 Wrote: Is there a way to create an If else statement for member profiles, for example, if I am looking at my member profile, I will see "this", and if looking at someone else's member profile  then I will see "that"


I've been trying, but can seem to get it.

any help?

<if $GLOBALS['mybb']->user['uid] then>looking at my member profile sees "this"<else> looking at someone else's profile sees "that"</if>

Solved:

Again, something inside me just takes over, and answers the question, so why do I even ask?

<if $GLOBALS['mybb']->user['uid'] == $memprofile['uid'] then>looking at my member profile sees "this"<else> looking at someone else's profile sees "that"</if>

But what if is a custom page?

(2022-01-01, 05:41 AM)Michael2014 Wrote: Is there a way to create an If else statement for member profiles, for example, if I am looking at my member profile, I will see "this", and if looking at someone else's member profile  then I will see "that"


I've been trying, but can seem to get it.

any help?

<if $GLOBALS['mybb']->user['uid] then>looking at my member profile sees "this"<else> looking at someone else's profile sees "that"</if>

(2022-01-01, 05:41 AM)Michael2014 Wrote: Is there a way to create an If else statement for member profiles, for example, if I am looking at my member profile, I will see "this", and if looking at someone else's member profile  then I will see "that"


I've been trying, but can seem to get it.

any help?

<if $GLOBALS['mybb']->user['uid] then>looking at my member profile sees "this"<else> looking at someone else's profile sees "that"</if>

Solved:

Again, something inside me just takes over, and answers the question, so why do I even ask?

<if $GLOBALS['mybb']->user['uid'] == $memprofile['uid'] then>looking at my member profile sees "this"<else> looking at someone else's profile sees "that"</if>

But what if is a custom page?

wow, solved this again, so surprising, it just takes minutes once the higher mind takes over, to solve this for a custom page is to change
$memprofile['uid'] then>
to
$uid then>
Hey man, what's up?
Reply
Not Solved
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)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/phptpl.php 92 errorHandler->error_callback
[PHP] {closure}
/inc/plugins/phptpl.php 109 preg_replace_callback_array
/inc/plugins/phptpl.php(70) : eval()'d code 19 phptpl_parsetpl
/forumdisplay.php 1547 phptpl_templates->get

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>
Reply
Not Solved
Try this (untested):
<if isset($foruminfo['fid']) && $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>
Reply
Not Solved
No change. Thanks for looking.
The plugin logic is too dense for me, so I can't begin to make a guess.
Reply
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
Not Solved
That's it. The fix is in and working. Smile
Thanks. Will consider testing more of the plugin features. In this case have only used it for a simple <if then> </if>.

Maybe I spoke too soon. Forum display is fixed, but post display has gone wild.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)