Equivalent of vBulletin's <if condition="THIS_SCRIPT != 'index'"> ?

The concept of THIS_SCRIPT from vBulletin doesn't really work in XenForo as the mechanism by which a page us built is so drastically different. However, Mike and I are investigating ways to expose some data from the controller and view layers that will hopefully give you tools to achieve what you want.
 
Ok tnx. Another one we use is <if condition="in_array($GLOBALS[forumid], array(25,118,120,121,126,139,140))">

I assume the same differences apply?
 
Ok tnx. Another one we use is <if condition="in_array($GLOBALS[forumid], array(25,118,120,121,126,139,140))">

I assume the same differences apply?
Our template syntax for conditionals currently only supports simple equality checks, but we plan to extend it in the near future.
 
Our template syntax for conditionals currently only supports simple equality checks, but we plan to extend it in the near future.

Hi Kier, hope you can really add this to the template system, really missing this feature :)

I have tried every possible combinations i can think of with AND, OR && ", ', { and more.... like for example:

Code:
<xen:if is="'{$forum.node_id} == 8' AND '{$forum.node_id} == 2'">

and

Code:
<xen:if is="'{$forum.node_id} == 8' &&  '{$forum.node_id} == 2'">

Are not giving me any errors but also not working :(
 
I think you need OR, not AND. The logic you posted there can never evaluate to true - how can the node_id ever be 8 AND 2?

Additionally, you don't need to individually quote each clause, that would turn the checks into strings instead of logic.

Try this instead:
HTML:
<xen:if is="{$forum.node_id} == 8 OR {$forum.node_id} == 2">
 
I think you need OR, not AND. The logic you posted there can never evaluate to true - how can the node_id ever be 8 AND 2?

Additionally, you don't need to individually quote each clause, that would turn the checks into strings instead of logic.

Try this instead:
HTML:
<xen:if is="{$forum.node_id} == 8 OR {$forum.node_id} == 2">

I did try OR but with the extra quotes :(

Without the quotes is working perfectly , thank you Kier!

Now I can go to sleep dreaming of beta two and you adding arrays in templates conditionals
 
The concept of THIS_SCRIPT from vBulletin doesn't really work in XenForo as the mechanism by which a page us built is so drastically different. However, Mike and I are investigating ways to expose some data from the controller and view layers that will hopefully give you tools to achieve what you want.

It's RC1, is it possible yet?
In another thread we want to say remove a block in the header from the register page. Checking against 'account' / 'profile' / 'login' / 'register' and a few others, quite handy.

Hope to hear soon :)
 
hmm if the route was visible I guess you could use that? Don't know if that is visible but that would definetly be a start.
 
Depending on how complicated you were willing to get, you could create an addon that does something based on:

Code:
$fc->route()->getControllerName() != 'XenForo_ControllerPublic_Index'
 
Aah yes, there we go. This is from XenForo_Dependencies_Abstract::preRenderView():
PHP:
if ($controllerResponse)
{
	$this->_defaultTemplateParams['controllerName']   = $controllerResponse->controllerName;
	$this->_defaultTemplateParams['controllerAction'] = $controllerResponse->controllerAction;
	$this->_defaultTemplateParams['viewName']         = $controllerResponse->viewName;
}
Therefore, you can access {$controllerName}, {$controllerAction} and {$viewName} from within templates and have just as much, if not more control than was ever possible using THIS_SCRIPT :)
 
THAT
is so
AWESOME

:D Thanks Kier for double checking. *runs to update templates and css*
 
page_container template:

Code:
<p class="importantMessage">
	controllerName: {$controllerName}, controllerAction: {$controllerAction} and viewName: {$viewName}.
</p>

examples:
 

Attachments

  • Screen shot 2011-02-06 at 10.21.33 AM.webp
    Screen shot 2011-02-06 at 10.21.33 AM.webp
    45.2 KB · Views: 84
  • Screen shot 2011-02-06 at 10.21.27 AM.webp
    Screen shot 2011-02-06 at 10.21.27 AM.webp
    45 KB · Views: 62
  • Screen shot 2011-02-06 at 10.21.23 AM.webp
    Screen shot 2011-02-06 at 10.21.23 AM.webp
    34.1 KB · Views: 57
  • Screen shot 2011-02-06 at 10.21.18 AM.webp
    Screen shot 2011-02-06 at 10.21.18 AM.webp
    43.9 KB · Views: 54
  • Screen shot 2011-02-06 at 10.20.54 AM.webp
    Screen shot 2011-02-06 at 10.20.54 AM.webp
    44.3 KB · Views: 54
  • Screen shot 2011-02-06 at 10.20.47 AM.webp
    Screen shot 2011-02-06 at 10.20.47 AM.webp
    44.1 KB · Views: 48
So what's the code for showing for example an ad only in forum ID 1 ? Or is that still not possible? The THIS_SCRIPT alternative isn't entirely clear to me either?
 
So what's the code for showing for example an ad only in forum ID 1 ? Or is that still not possible? The THIS_SCRIPT alternative isn't entirely clear to me either?
If you want to show an ad only in forum id 1, use this:

<xen:if is="{$forum.node_id} == 1"><!-- ad code here --></xen:if>

If you want to show something only on thread display pages, you could use this in vBulletin:

<if condition="THIS_SCRIPT == 'showthread'"><!-- your stuff here --></if>

Or this in XenForo:

<xen:if is="{$controllerName} == 'XenForo_ControllerPublic_Thread' AND {$controllerAction} == 'index'"><!-- your stuff here --></xen:if>
 
Top Bottom