MyBB Hacks

Full Version: PHP in Templates / Complex Templates
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
(04-21-2010 01:10 AM)Rateu Wrote: [ -> ]May I know what actually do you want to do?

I'm trying to use the <if $CONDITION then></if> conditionals to display certain links in the header/navigation to only members of certain usergroups.

All of my <if></if> and PHP code is being output to the browser - it's obvious the mod is not functional and is not parsing the code...
Did you try this condition:

Code:
<if $mybb->user['usergroup'] == x then>
Your link here
</if>


Change the x with user group id.

(04-21-2010 01:39 AM)Rateu Wrote: [ -> ]Did you try this condition:

Code:
<if $mybb->user['usergroup'] == x then>
Your link here
</if>


Change the x with user group id.


Yes.  This is not a syntax error.

If I put that in a template with 'x' replace with '1' (Guests) and view my forum logged in as Admin (shouldn't display) it still displays. If you were to view source you will see this in the source:

Code:
<if Array['usergroup'] == 1 then>
Your link here
</if>


The plugin seems to be installed wrong (maybe because it doesn't include any instructions) or not functional - for whatever reason.



EDIT: I've posted a detailed update of this issue here: http://community.mybboard.net/thread-318...http://community.mybboard.net/thread-31860-post-492659.html
Did you try it in a fresh MyBB installation?
Instructions are here - I'm just too lazy to redocument everything for all these plugins.
But from your descriptions, it does sound like the plugin isn't activated at all, although you seem to be doing the right things.  As suggested, try it on a clean install of MyBB 1.4.11-13 (haven't tested it on .13, though it shouldn't be different there) and see if it works.
I've tested in MyBB 1.4.13. It works perfectly.
I am trying to build a set up for a book review forum and I thought it would be cute if the replies to the book review post had the users avatar as an icon for "who posted".

I have this working fine for posts by users, but I have forum settings set so that guests can post. Of course, guests have no avatar, so I wanted to use the php/templates Conditionals plug in to put an IF statement around the avatar image - something along the lines of

<if {post is by a guest} then <show this image> else {show posters avatar}.

This is the HTML I am using to get the small avatar to show (miniav is a .css class I made for the borders/styling on the avatar). This is working fine. Its the swap for the guest image I am struggling with. I have a default avatar set up on my forum, that is the image I want to link to.

Code:
<td class="tcat">
       <div class="float_left smalltext">
	      <img src="{$post['avatar']}" class="miniav" "width="35" height="35" /><strong>
              <span class="smalltext">&nbsp;{$post['profilelink']}</span></strong> - 
	          {$post['postdate']}, {$post['posttime']}<span id="edited_by_{$post['pid']}"></span>
	</div>
	          {$post['posturl']}
</td>


Here is a link to an example:  http://www.leefish.nl/mybb/showthread.php?tid=33 Once this is all polished up I hope to post it here in the XThreads examples forum - so I want it to be REALLY nice Smile

I don't know which variable to call. Can anyone help?

Try something like this:

Code:
<if $post['avatar'] then>
<img src="{$post['avatar']}" class="miniav" "width="35" height="35" />
<else>
<img src="image_path_for_guest_avatar" alt="" title="" />
</if>

Thank you RateU. Indeed, I was thinking along the lines of <ïf poster was guest> but I see you cut the middle man out and went straight for <if the image defined as an avatar is there then blah blah>. I see.
I merged the thread Smile

Yes, the code not only for guest, but for member who doesn't have avatar too. You can use $post['uid'] if you really want it for guest only.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
Reference URL's