How to convert an admin option into an array?

0ptima

Well-known member
Im trying to hide polls in certain forums and would like to configure which forums will not have polls in the Admin CP.

I created a new option with a comma delimited value
upload_2013-9-5_19-51-41.webp

In the thread_create template, I want to access this option, but I need it in an array format as the following will not work
upload_2013-9-5_19-53-53.webp

How can I achieve this? Thanks.
 
If you do this, what does it print out:
Code:
{xen:helper dump, array({xen:raw $xenOptions.hidePolls})}
 
This
{xen:helper dump, $xenOptions}

(got a syntax error with your code)

printed
["zhidepolls"] => string(21) "s:14:"13,14,38,59,60""

(Ive been fiddling with the option so its not quite the same as when I first posted.)
 
If I change it to array, I get this error

  • Data Type:
    Please select a data type other than 'array' if you want to allow single selections only.
  • Array Sub-Options:
    Please enter a list of sub-options for this array.

What is a sub-option?
 
That is a string var. It doesn't eval like you are thinking. You can check individual values using PHP code (explode the string, process the individual array elements). If you are wanting to do this using template syntax then you need to explode the string in PHP, pass the resulting array to the template, then use in_array() on it.
 
Another (perhaps better) option is to change your option to be an array type instead of a string type.
 
That is a string var. It doesn't eval like you are thinking. You can check individual values using PHP code (explode the string, process the individual array elements). If you are wanting to do this using template syntax then you need to explode the string in PHP, pass the resulting array to the template, then use in_array() on it.

Where would I execute the PHP code?
 
You'd want to extend the controller for creating a thread to interject your split array into the view params.
 
Back
Top Bottom