Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 PHp conditions in an XThreads Template
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #1
PHp conditions in an XThreads Template
Hi,

I have a board with several downloads forums. They are all using the same set of Xthreads templates, just with different skins. The creators of the items for download all specialise in different fields, so it makes sense to keep them apart, and they see their forum as a mini site for them within my board.

In each of the forums in the forumdisplay threadlist I have a filter set up to filter downloads based on the Xthreads fields. It would be neat to have an option in the template to "jump" to the other creators downloads forum (this is the easy bit) but it would be VERY cool if the list could be dynamic.

For example:

in creator A's forum there are links to creators B,C and D.
in creator B's forum there are links to creators A,C and D.
in creator C's forum there are links to creators A,B and D.
in creator D's forum there are links to creators A,B and C.

I tried using the below method to "hide" the extra link but no luck. It was hidden everywhere. The list is in the forumdisplay_threadlist

HTML Code
1
2
3
4
5
6
7
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder" style="clear: both;">
			   	<tr><td class="thead"><strong>Game</strong></td></tr>
                                <tr><td class="fancy"></td></tr>
				<tr><td class="trow1"><a href="forumdisplay.php?fid={$fid}"><span><strong>Both</strong></span></a></td></tr>
				<if $forum['fid'] == 53 then><tr><td class="trow2"><a href="{$forumurl_q}filtertf_prefix=Sims2"><span style="color: blue;"><strong>Sims2</strong></span></a></td></tr><else>
				<tr><td class="trow2"><a href="forumdisplay.php?fid={$fid}&amp;filtertf_prefix=Sims3"><span style="color: green;"><strong>Sims3</strong></span></a></td></tr>
                         </table></if>


Is there a way to do this?



[Image: leelink.gif]
MYBB1.6 & XThreads
(This post was last modified: 10-05-2010 10:05 AM by leefish.)
10-05-2010 09:05 AM
Visit this user's website Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #2
RE: PHp conditions in an XThreads Template
You probably want to stick the </if> before </table>

I'm guessing you're using PHP in Templates plugin?

My Blog
10-05-2010 11:47 AM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #3
RE: PHp conditions in an XThreads Template
Yes, I am using php in templates. Its not that it gives an error, it just hides the link

HTML Code
1
2
3
4
5
6
7
                        <table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder" style="clear: both;">
                        <tr><td class="thead"><strong>Game</strong></td></tr>
                                <tr><td class="fancy"></td></tr>
				<tr><td class="trow1"><a href="forumdisplay.php?fid={$fid}"><span><strong>Both</strong></span></a></td></tr>
								<if $forum['fid'] == 7 then><tr><td class="trow2"><a href="{$forumurl_q}filtertf_prefix=Sims2"><span style="color: green;"><strong>Sims2</strong></span></a></td></tr>
				<else><tr><td class="trow2"><a href="forumdisplay.php?fid={$fid}&amp;filtertf_prefix=Sims3"><span style="color: blue;"><strong>Sims3</strong></span></a></td></tr></if>
</table>



So in the code above, if I was in Forum 7 I would expect to see the link to sims2 and sims3. I just see the sims3 link. If I go to another forum using the same templates I still only see the sims 3 link. Is it because I am in forumdisplay?



[Image: leelink.gif]
MYBB1.6 & XThreads
10-05-2010 12:02 PM
Visit this user's website Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #4
RE: PHp conditions in an XThreads Template
Oh okay, I see what you mean.

Try using $fid instead of $forum['fid'] in the conditional (MyBB is very inconsistent, they actually use $forum_info or something like that in forumdisplay).

My Blog
(This post was last modified: 10-05-2010 04:15 PM by ZiNgA BuRgA.)
10-05-2010 04:14 PM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #5
RE: PHp conditions in an XThreads Template
Hi Zinga - I'm gonna try and keep this short Smile

As in the code above, the only change being the replacements as listed below:

I tried replacing $forum['fid'] with $forum{$fid} and the result was as in my previous post - no errors, just hidden.
I tried replacing $forum['fid'] with $forumdisplay{$fid} and the result was as in my previous post - no errors, just hidden.

Then I tried replacing $forum['fid'] with {$fid} and I got an error and my whole forumdisplay was gone - just left with header and footer etc. Error as below.

Code:
Parse error: syntax error, unexpected '{', expecting ')' in /customers/leefish.nl/leefish.nl/httpd.www/mybb/forumdisplay.php(1193) : eval()'d code on line 17


So based on the output above I tried replacing $forum['fid'] with ($fid) and the result was as in my previous post - no errors, just hidden.



[Image: leelink.gif]
MYBB1.6 & XThreads
10-05-2010 10:00 PM
Visit this user's website Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #6
RE: PHp conditions in an XThreads Template
It should be just $fid without any surrounding brackets, though ($fid) should work too.

Here's the code I've got working:

HTML Code
1
2
3
4
5
6
7
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder" style="clear: both;">
                        <tr><td class="thead"><strong>Game</strong></td></tr>
                                <tr><td class="fancy"></td></tr>
				<tr><td class="trow1"><a href="forumdisplay.php?fid={$fid}"><span><strong>Both</strong></span></a></td></tr>
								<if $fid == 7 then><tr><td class="trow2"><a href="{$forumurl_q}filtertf_prefix=Sims2"><span style="color: green;"><strong>Sims2</strong></span></a></td></tr>
				<else><tr><td class="trow2"><a href="forumdisplay.php?fid={$fid}&amp;filtertf_prefix=Sims3"><span style="color: blue;"><strong>Sims3</strong></span></a></td></tr></if>
</table>


BTW, for what you're doing, you may prefer a "!=" comparison rather than a "==", eg:

HTML Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder" style="clear: both;">
                        <tr><td class="thead"><strong>Game</strong></td></tr>
                                <tr><td class="fancy"></td></tr>
				<tr><td class="trow1"><a href="forumdisplay.php?fid={$fid}"><span><strong>Both</strong></span></a></td></tr>



<if $fid != 7 then>
<tr><td class="trow2"><a href="{$forumurl_q}filtertf_prefix=Sims2"><span style="color: green;"><strong>Sims2</strong></span></a></td></tr>
</if>

<if $fid != 8 then>
<tr><td class="trow2"><a href="{$forumurl_q}filtertf_prefix=Sims3"><span style="color: green;"><strong>Sims3</strong></span></a></td></tr>
</if>

<if $fid != 9 then>
<tr><td class="trow2"><a href="{$forumurl_q}filtertf_prefix=Sims4"><span style="color: rainbow;"><strong>Sims4</strong></span></a></td></tr>
</if>

</table>


My Blog
10-05-2010 10:41 PM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #7
RE: PHp conditions in an XThreads Template
Thank you Zinga - that seems to work fine. Thank you very much. Now off to the pencil and paper to make a logical split Smile


[Image: leelink.gif]
MYBB1.6 & XThreads
(This post was last modified: 10-06-2010 02:20 AM by leefish.)
10-06-2010 02:19 AM
Visit this user's website Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: