Log in

View Full Version : Multiple options in custom bbcode


Aurons Ghost
08-27-2006, 11:19 AM
I have a story archive associated with my site and I am trying to set up some bbcode that can easily link to those stories and to chapters within those stories.

story urls are http://stories.mysite.net/viewstory.php?sid=Story ID
and chapter urls are http://stories.mysite.net/viewstory.php?sid=Story ID&chapter=Chapter number

I know I can get the first to work simply with:

{param}
<a href="http://stories.mysite.net/viewstory.php?sid={option}">{param}</a>


but I don't know how to do the second, or even if it's possible. I think it should be like this:

{param}
<a href="http://stories.mysite.net/viewstory.php?sid={option1}&chapter={option2}">{param}</a>


I would guess I need to make a plugin for this to work, how would I go about doing this, if it's possible at all?

(I'm on 3.5.4 if that's any help)

Renmiri
08-27-2006, 03:49 PM
It is possible but...

From class_bbcode.php:

/**
* Allows extension of the class functionality at run time by calling an
* external function. To use this, your tag must have a callback of
* 'handle_external' and define an additional 'external_callback' entry.
* Your function will receive 3 parameters:
* A reference to this BB code parser
* The value for the tag
* The option for the tag
* Ensure that you accept at least the first parameter by reference!
*
* @param string Value for the tag
* @param string Option for the tag (if it has one)
*
* @return string HTML representation of the tag
*/
function handle_external($value, $option = null)....


So you would have to have a bbcode that called on handle_external($value,$option) and split it

Something like that
<a href="http://stories.mysite.net/viewstory.php?sid=explode_option({option})[0]&chapter=explode_option({option})[1]">{param}</a>


where explode_option($value) was your function..

Optionally, the bbcode parser does parse javascript so you could make do with a javascript function that returned the proper URL

kk, found a mod that taught me how to call "handle external" procedures for bbcodes.
vB Code [table] (https://vborg.vbsupport.ru/showthread.php?t=107985)

Using the xml file it is pretty straight forward. All you need is to import the plugin and create a bbcode for [chapter] with a blank replacement string