The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
[SOLVED] vbulletin doesn't like ternary operators?
for simplistic code sake I'm trying to use ternary operators in my products.
Here's what im trying to simplify: Code:
if ($vbulletin->options['drc_embed_vine_smpl']) { $drc_embed_vine = '<iframe src="https://vine.co/v/$2/embed/simple" width="480" height="480" frameborder="0"></iframe>'; } else { $drc_embed_vine = '<iframe src="https://vine.co/v/$2/embed/postcard" width="480" height="480" frameborder="0"></iframe>'; } Code:
$drc_embed_vine = '<iframe src="https://vine.co/v/$2/embed/'.(($vbulletin->options['drc_embed_vine_smpl']) ? "simple" : "postcard").'" width="480" height="480" frameborder="0"></iframe>'; Code:
$drc_embed_vine='<iframe src="https://vine.co/v/$2/embed/'.(($vbulletin->options['drc_embed_vine_smpl'])?'simple':'postcard')).' width="480" height="480" frameborder="0">'; Code:
$drc_embed_vine='<iframe src="https://vine.co/v/$2/embed/'.(($vbulletin->options[\'drc_embed_vine_smpl\'])?'simple':'postcard')).' width="480" height="480" frameborder="0">'; although Code:
$drc_embed_vine = '<iframe src="https://vine.co/v/$2/embed/'.(($vbulletin->options['drc_embed_vine_smpl']) ? "simple" : "postcard").'" width="480" height="480" frameborder="0"></iframe>'; btw Code:
$vbulletin->options['drc_embed_vine_smpl'] where am i going wrong =/ |
#2
|
|||
|
|||
vBulletin does like it, it's just that you probably use the if statement wrong of the ternary operator.
Does $vbulletin->options['drc_embed_vine_smpl'] literally contain a boolean: true/false or does it contain a number 1 (true) and 0 (false)? If it's really a boolean, then the following should work just fine: PHP Code:
PHP Code:
|
Благодарность от: | ||
Dr.CustUmz |
#3
|
||||
|
||||
It does return a number, but for some reason it still not working, the option exist. I do toggle it one to the other, but it always shows postcard.
I Tried Code:
($vbulletin->options['drc_embed_vine_smpl'] === 1 ? "simple" : "postcard") Code:
($vbulletin->options['drc_embed_vine_smpl'] == 1 ? "simple" : "postcard") Code:
<hookname>postbit_display_complete</hookname> <phpcode><![CDATA[ $drc_embed_vine = '<iframe src="https://vine.co/v/$2/embed/'.($vbulletin->options['drc_embed_vine_smpl'] == 1 ? "simple" : "postcard").'" width="480" height="480" frameborder="0"></iframe>'; $this->post['message'] = preg_replace('~(<a href="https?://vine.co)/v/(.*)" target="_blank">(https?://vine.co)/v/(.*)<\/a>~', $drc_embed_vine, $this->post['message']); ]]></phpcode> Code:
<setting varname="drc_embed_vine_smpl" displayorder="1"> <datatype>boolean</datatype> <optioncode>yesno</optioncode> <defaultvalue>1</defaultvalue> </setting> |
#5
|
||||
|
||||
i placed it at the beginning of the plugin, this is what it spat out in my showthread.
|
#6
|
||||
|
||||
Adding the product for reference
I changed the option in this version, thinking maybe i had a conflict, but no luck |
#7
|
|||
|
|||
drc_embed_vine_smpl is not defined in your import file. I think you're using the wrong variable.
|
#8
|
||||
|
||||
i change it all to "drc_ae_vine_styl" in that version attached thinking maybe I had a conflict somewhere.
|
#9
|
||||
|
||||
I think you need to globalize $vbulletin in the postbit_display_complate hook location.
|
2 благодарности(ей) от: | ||
Dr.CustUmz, MarkFL |
#10
|
||||
|
||||
Quote:
this is as simple as adding Code:
global $vbulletin; --------------- Added [DATE]1463174769[/DATE] at [TIME]1463174769[/TIME] --------------- yup, THANK YOU SO MUCH LYNNE! I had no clue why this wouldn't work, so for future ref. how do I know when I need to globalize a var other than just giving it a shot lol |
Благодарность от: | ||
MarkFL |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|