PDA

View Full Version : Rotating images in an article


fpena
06-16-2008, 04:41 PM
Hello,

I'd like to implement a feature in my articles where I can rotate a variety of images within an article. I don't need them to rotate while on the screen but I'd like for them to do so when I refresh the page.

Within VB Dynamics itself I have a solution that works great within a module. I create a Plugin that defines all of the random images then within a template I simply state, "$random_banner[$random_number]" and it rotates the images after each refresh. (I found that code in this thread: http://www.vbadvanced.com/forum/showthread.php?t=29211)

I tried to do the same thing in an article by using the custom BB Code that was mentioned in this thread: http://www.vbadvanced.com/forum/showthread.php?t=19758

What is happening though is when I type the "$random..." statement in the place of the image directory/name it thinks I am asking for a filename that is on the Dynamics directory and is named "$random..." so I get a RED-X for a missing image.

What can I do to get this to work? All I want is an image embedded into my article but for it to change each time I refresh it.

Thanks!

Brian
06-16-2008, 06:32 PM
Sorry, but I don't think there's going to be a way to pass variables within BB code.

Our Sponsors
 

fpena
06-16-2008, 07:15 PM
Sorry, but I don't think there's going to be a way to pass variables within BB code.

Could I instead enable HTML in the article and use that? If not I'll just figure out a way to add the image before or after the article in the template.

Brian
06-16-2008, 08:44 PM
HTML would not work either. Now that I think about it though, you can probably just use the variables like you have been and add a new plugin to the 'vba_dyna_showentry_quickreply' hook location with the following code:
$entry['pagetext_parsed'] = str_replace('$random_banner[$random_number]', $random_banner[$random_number], $entry['pagetext_parsed']);

That should allow the text from the article to be replaced with the value the actual PHP code is printing out.

Our Sponsors
 

fpena
06-16-2008, 09:13 PM
HTML would not work either. Now that I think about it though, you can probably just use the variables like you have been and add a new plugin to the 'vba_dyna_showentry_quickreply' hook location with the following code:
$entry['pagetext_parsed'] = str_replace('$random_banner[$random_number]', $random_banner[$random_number], $entry['pagetext_parsed']);

That should allow the text from the article to be replaced with the value the actual PHP code is printing out.

Wow that worked perfectly!!! You rock!!! :D

Thanks!