![]() |
Looping
Im trying to get my head round more of this plugin stuff.
In vB options I have a textarea. I explode that out into an array then I want to loop each item to display in an unordered list where ever on the template. How can I make this more compatable with vB? PHP Code:
|
Your only issue is the second <ul> tag. It should be a closing </ul> instead. Aside from that it should work, as long as the $vbulletin->options['html'] variable has newline characters in it. Otherwise it will all display on one line.
As a matter of convension, you should change those option names, go with a prefix like... $vbulletin->options['mymod_enabled'] $vbulletin->options['mymod_html'] That way nothing interferes with one another later on down the road. |
Sorry that was a problem with my syntax but the original problem still exists.
How can I display this loop in a template? Would it be best to write whatever the loop outputs to a template then include that template on another template? If so, how would I do that? |
You need to put that php in a plugin - php cannot go into a template.
|
Yeah I know, I've got trouble showing the contents of this plugin though.
|
To get it in a template, you shouldn't echo. You need to stuff it into a variable like $output_list.
PHP Code:
Code:
<if condition="$vbulletin->options[mymod_enabled]"> |
That doesn't work :|
|
You may want to check if items exist in $items first.
|
Yeah there is.
|
I meant add a PHP code check, and then you can just do (in the template):
Code:
<if condition="$output_list">$output_list</if> |
All times are GMT. The time now is 06:39 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|