Not Solved Two variable in single code
#1
Not Solved
Please help me to put code through template condition by using if.

I want to show last post of specific forum to specific group.
How to do it?

<if in_array($mybb->user['usergroup'],array(4,9)) ; here i also want to add forum id  then>
{last post}
</if.
please help me to proper code for this
Reply
#2
Not Solved
Not sure if that's the variable you're looking for, but;

<if in_array($mybb->user['usergroup'],array(4,9)) and {$forum['fid']} then>{last post}</if>
Reply
#3
Not Solved
i use below code
<if (in_array($mybb->user['usergroup'], array(4,8,9)) && in_array($forum['fid'], array(168))) then>

<span class="smalltext">
<a href="{$lastpost_link}" title="{$full_lastpost_subject}"><strong>{$lastpost_subject}</strong></a>
<br />{$lastpost_date}<br />{$lang->by} {$lastpost_profilelink}</span>

<else> Protected Forum
</if>

But it show 'Protected Forum' under all forum last post rather than in forum id 168.
Is there any issue with code?
Reply
#4
Not Solved
Please Help someone...
Reply
#5
Not Solved
Its Look Simple but no one want to correct this code?
Please help?
Reply
#6
Not Solved
Can anyone help in this matter?
i tried in many way but not working.
I will be very thankful to you guys.
Reply
#7
Not Solved
That's obvious when you realize you're checking for the forum identifier existence.

if (in_array($forum['fid'], [168])) {
  // Display something if you're viewing the forum with ID 168
}

If you want to display the last post of a specific forum in every forum you must write some low level code, selecting your desired info from the database since the last post data of a specific thread is available only when you watch a specific forum. Using PHP in templates is not enough for this task, or it might be extremely inefficient.
[Image: fSGNVQj.png]
Reply
#8
Not Solved
Thanks shade.

Can you modify below code please for me.

<if (in_array($mybb->user['usergroup'], array(4,8,9)) && in_array($forum['fid'], array(168))) then>

<span class="smalltext">
<a href="{$lastpost_link}" title="{$full_lastpost_subject}"><strong>{$lastpost_subject}</strong></a>
<br />{$lastpost_date}<br />{$lang->by} {$lastpost_profilelink}</span>

<else> Protected Forum
</if>

Reply
#9
Not Solved
I guess you didn't read the whole post then. You cannot accomplish what you are asking just by using PHP in templates. You must hook into MyBB's core code and select the latest post of your target thread/forum from the database.
[Image: fSGNVQj.png]
Reply
#10
Not Solved
Thanks..
I am not expert.
can you guide me please.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)