Yes, and the actual code is quite long and confusing. I was just looking for the array set up correctly and then called correctly in that spot.
Printable View
Yes, and the actual code is quite long and confusing. I was just looking for the array set up correctly and then called correctly in that spot.
I, too, fail to understand your question.
Do you mean to set up something like this:... selecting between arrays of options, then further refining the selection with another ternary operator? This seems elegant, if inefficient.Code:(condition1 ? array(option1, option2) : array(option3, option4))[condition2 ? 0 : 1];
Okay here is the section:
What I have done so far is to make 9 other pop ups. so the 'title' and 'description' is currently set up as an either : or situation.PHP Code:foreach (array_keys($context['smileys']) as $location)
$context['smileys'][$location] = array(
'id' => $location,
'title' => $location == 'postform' ? $txt['smileys_location_form'] : $txt['smileys_location_popup'],
'description' => $location == 'postform' ? $txt['smileys_location_form_description'] : $txt['smileys_location_popup_description'],
'last_row' => count($context['smileys'][$location]['rows']),
'rows' => array_values($context['smileys'][$location]['rows']),
);
I wanted to make it either : or, or, or ...
Looking for different ways to do this without having to rewrite the entire coding for 12 different php files.
Looking at the post above, gave me the idea to have the "or" part be an array in itself. so it would be either : (array)
where array would = or, or, or...
Something like:Quote:
I wanted to make it either : or, or, or ...
?Code:(condition1 ?
either1 :
(condition2 ?
either2 :
(condition3 ?
or1
)
)
)
Not quite. I apologize for being obtuse. I don't know how to explain it well I guess.
Here is another attempt.
What this script does, is shows a table. As it stands the table has 2 boxes inside it. The first is postform. the $txt part is the title of the postform's box. The other side of the : is the pop up box. (bt, the boxes contain a visual of what is contained in the actual post form and actual pop up).PHP Code:'title' => $location == 'postform' ? $txt['smileys_location_form'] : $txt['smileys_location_popup'],
'description' => $location == 'postform' ? $txt['smileys_location_form_description'] : $txt['smileys_location_popup_description'],
I have made a total of 10 boxes. In this case, the one postform, and then 9 popups.
With the code as it is, the post form uses it's $txt as the title, but the other 9 'popup' boxes share the same $txt, so even though they are different they have the same title.
What I am attempting is to make it so it says something like:
Where I would define $array and $array2 as something like:PHP Code:'title' => $location == 'postform' ? $txt['smileys_location_form'] : $array,
'description' => $location == 'postform' ? $txt['smileys_location_form_description'] : $array2,
In the hopes that the 9 pop up boxes in this table would then take on their own titles.PHP Code:$array = ($txt['smileys_location_popup'], $txt['smileys_location_popup_a'], $txt['smileys_location_popup_b'], $txt['smileys_location_popup_c'], ..etc),
Does that make sense?
I know this is trial and error here, Which is why my original question was on the php code syntax, was it correct. Knowing if there were errors in the code would help when I get a parse error on the page. If I know the code is written correctly then I would know it wasn't that causing the errors. :D
Like that?Code:$i = 0;
'title' => $location == 'postform' ? $txt['smileys_location_form'] : $array[$i++],
'description' => $location == 'postform' ? $txt['smileys_location_form_description'] : $array2[$i++],
Shouldn't that comparison operator be === ? Comparing and assigning a value?Quote:
Code:'title' => $location == 'postform' ? $txt['smileys_location_form'] : $array[$i++],
'description' => $location == 'postform' ? $txt['smileys_location_form_description'] : $array2[$i++],
Erm... no? === is for non-type-casting comparison. It could be used there, certainly, but no assignment is involved.
Oops. Sorry, I thought it was something else. I guess I'll have to do my reading :rolleyes:
Cool. I will try that out and let you know what happens.
Thanks guys!