The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
Help with if condition
Hello I have this array
PHP Code:
PHP Code:
HTML Code:
<vb:if condition="$rep.thread != 0"> <td style="padding : 3px;"><a href="{$rep.thread}">View</a></td> <vb:else /> <td style="padding : 3px;">n/a</td> </vb:if> is there another way i can say if $rep.thread doenst = 0 then show the thread link? |
#2
|
||||
|
||||
Where do you have $rep.thread defined in your code?
If your not sure if your variable is working try to use var_dump($var); if it returns NULL you have a problem unless it is supposed to return NULL. |
#3
|
||||
|
||||
You condition should be:
HTML Code:
<vb:if condition="$rep['thread'] != 0">
|
#4
|
|||
|
|||
I think you need to provide more info than you have already. Is those first 2 sets of codes from plugins ye? And if so I presume you're trying to get that variable into the if statement ye?
I think it all depends on how this $rep['thread'] or $rep.thread is defined. If you're trying to define it inside a plugin then it needs to be registered or pre-registered (if used in an existing template). And then the format for using the variable (outside of the if statements as if statements are different) would be more like {vb:raw $rep.thread} (for your a href link. But yeah for the if statement you cant use the same format. You do it the same way as you would use to. So yeah what Lynne suggested should be what you need for the if statement. Though it would still need to be registered inside the plugin. There's a few good vb4 articles which shoudl help: https://vborg.vbsupport.ru/showthread.php?t=228078 https://vborg.vbsupport.ru/showthread.php?t=231525 |
#5
|
||||
|
||||
I am sorry. Thank you consolegaming for the links I am reading them now. Oh yes I have seen these. Thanks though.
Here is the page, view_rep.php PHP Code:
And here is the whole template page: view_userrep HTML Code:
{vb:stylevar htmldoctype} <html xmlns="https://www.w3.org/1999/xhtml" dir="{vb:stylevar textdirection}" lang="{vb:stylevar languagecode}"> <head> <!-- no cache headers --> <meta http-equiv="Pragma" content="no-cache" /> <meta http-equiv="Expires" content="-1" /> <meta http-equiv="Cache-Control" content="no-cache" /> <!-- end no cache headers --> {vb:raw headinclude} <title>{vb:raw pagetitle}</title> </head> <body> {vb:raw header} {vb:raw navbar} <div class="blockhead">{$username}'s iRep Profile</div> <div class="blockbody"> <div class="blockrow"> <table cellpadding="5" cellspacing="1" border="1" width="100%" style="border: 1px solid #333333;"> <tr> <th width="10%" style="text-align: center; font-weight: bold;">From</th> <th width="20" style="text-align: center; font-weight: bold;">Rating</th> <th width="10%" style="text-align: center; font-weight: bold;">Reason</th> <th width="10%" style="text-align: center; font-weight: bold;">Thread URL</th> <th width="70%" style="text-align: center; font-weight: bold;">Comment</th> </tr> <vb:each from="reparray" value="rep"> <tr> <vb:if condition="$rep.username"> <td style="padding : 3px;"><a href="{vb:var rep.userlink}" title="{$rep.username} user profile">{$rep.username}</a></td> <vb:else /> <td style="padding : 3px;font-weight:bold;text-align:center;">System</td> </vb:if> <td style="text-align: center;"><img src="{vb:var rep.ratedimg}" alt="{vb:var rep.ratedtext}" /></td> <td style="padding : 3px;">{vb:var rep.reason}</td> <vb:if condition="$rep.thread != 0"> <td style="padding : 3px;"><a href="{$rep.thread}">View</a></td> <vb:else /> <td style="padding : 3px;">n/a</td> </vb:if> <td>{vb:var rep.message}</td> </tr> </vb:each> </table> </div> </div> {vb:raw footer} </body> </html> If I change it to: HTML Code:
<vb:if condition="$rep.thread"> <td style="padding : 3px;"><a href="{$rep.thread}">View</a></td> </vb:if> |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|