• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Pulling information within $xenOptions

gldtn

Well-known member
#1
Hello guys, I'm try to set an option for my add-on where I can just specify several node_id's and if it matches the node id's it will return my phrase like so:

PHP:
<xen:if is="in_array({$forum.node_id}, array({$xenOptions.gl_tav_node_id}))">
    {xen:phrase gl_tav_post_new_thread}
<xen:else />
    {xen:phrase post_new_thread}
</xen:if>
What am I doing wrong here?

Thanks!
 

Jake Bunce

XenForo moderator
Staff member
#2
What format is the "gl_tav_node_id" option stored as? If it's already an array then you can use this:

Code:
<xen:if is="in_array({$forum.node_id}, {$xenOptions.gl_tav_node_id})">
Otherwise you can't use in_array.
 

gldtn

Well-known member
#3
It's stored as a text because all I wanted for now is to be able to enter the node ID as follow:

2, 10, 15 - Seems like if I store as an array I'll have to make some kind of php callback to find out which node the user add and allow them to select from a menu. Or is there a way around it?

I tried
Code:
<xen:if is="{$forum.node_id} == {$xenOptions.gl_tav_node_id}">
but all it does, just like the code I put above, it returns the first node only.

Any suggestions Jake?

Thanks for the response.
 

gldtn

Well-known member
#4
Jake, thanks once again for this.. I was able to make a selection menu to render the nodes and allow user to select it and use the corrected code above that you supplied.

Thank you very much for this!
 

gldtn

Well-known member
#7
Hmm, I hate not knowing php, I tried doing a search on google, but I still wasn't able to figure it out. If some of the php gurus could give me a hand I'd appreciate it.

I've set four different options in which each defines the node id in array. Now I want it to find out if the node id is a certain type and if it is, return a certain phrase or a template.

Phrase code:
PHP:
<xen:if is="in_array({$forum.node_id}, {$xenOptions.gars_articleType_nodeId})">
    {xen:phrase gars_articleType_post_new_thread}
<xen:elseif is="in_array({$forum.node_id}, {$xenOptions.gars_tutorialType_nodeId})" />
    {xen:phrase gars_tutorialType_post_new_thread}
<xen:elseif is="in_array({$forum.node_id}, {$xenOptions.gars_reviewType_nodeId})" />
    {xen:phrase gars_reviewType_post_new_thread}
<xen:elseif is="in_array({$forum.node_id}, {$xenOptions.gars_strainType_nodeId})" />
    {xen:phrase gars_strainType_post_new_thread}
<xen:else />
    {xen:phrase post_new_thread}
</xen:if>
Template code:
PHP:
<xen:if is="in_array({$forum.node_id}, {$xenOptions.gars_strainType_nodeId})">
    <xen:include template="gars_strainType_thread_list" />
<xen:elseif is="in_array({$forum.node_id}, {$xenOptions.gars_articleType_nodeId})" />
    <xen:include template="gars_articleType_thread_list" />
<xen:else />
If I only have one elseif like the template code, it returns fine without error, or if the array is the first option then everything is good.

It's telling me it's a Wrong datatype for second argument
Code:
    in_array() [<a href='function.in-array'>function.in-array</a>]: Wrong datatype for second argument in /home/cogumelo/public_html/comunidade/internal_data/templates/S.9,L.1,forum_view.php, line 85
    in_array() [<a href='function.in-array'>function.in-array</a>]: Wrong datatype for second argument in /home/cogumelo/public_html/comunidade/internal_data/templates/S.9,L.1,forum_view.php, line 91
    in_array() [<a href='function.in-array'>function.in-array</a>]: Wrong datatype for second argument in /home/cogumelo/public_html/comunidade/internal_data/templates/S.9,L.1,forum_view.php, line 4439
    in_array() [<a href='function.in-array'>function.in-array</a>]: Wrong datatype for second argument in /home/cogumelo/public_html/comunidade/internal_data/templates/S.9,L.1,forum_view.php, line 4445