Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: nexpb - huhtikuu 05, 2014, 01:47:54 IP

Otsikko: Problem when creating custom bbcode
Kirjoitti: nexpb - huhtikuu 05, 2014, 01:47:54 IP
How can I use the value $1 as parameter in a php function?

example:
[tag]name[/tag]
name would be $1 so I want to use the method getSerie($1)
Otsikko: Re: Problem when creating custom bbcode
Kirjoitti: nexpb - huhtikuu 14, 2014, 01:46:07 IP
bump
Otsikko: Re: Problem when creating custom bbcode
Kirjoitti: margarett - huhtikuu 14, 2014, 02:47:38 IP
I'm not really sure on what you want to do, neither exactly how parse_bbc works, unfortunately.

But if you look at, eg, the "email" BBC

array(
'tag' => 'email',
'type' => 'unparsed_content',
'content' => '<a href="mailto:$1" class="bbc_email">$1</a>',
// !!! Should this respect guest_hideContacts?
'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array(\'<br />\' => \'\'));'),
),

$1 goes into the link construction directly, so I assume you can just use it straight on.

You can check other BBC codes in Subs.php, function parse_bbc, maybe it will give you a better overview.
Otsikko: Re: Problem when creating custom bbcode
Kirjoitti: nexpb - huhtikuu 16, 2014, 10:47:07 AP
Lainaus käyttäjältä: margarett - huhtikuu 14, 2014, 02:47:38 IP
I'm not really sure on what you want to do, neither exactly how parse_bbc works, unfortunately.

But if you look at, eg, the "email" BBC

array(
'tag' => 'email',
'type' => 'unparsed_content',
'content' => '<a href="mailto:$1" class="bbc_email">$1</a>',
// !!! Should this respect guest_hideContacts?
'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array(\'<br />\' => \'\'));'),
),

$1 goes into the link construction directly, so I assume you can just use it straight on.

You can check other BBC codes in Subs.php, function parse_bbc, maybe it will give you a better overview.
The thing is I want to use the value to call my php function what I want to achieve is someting like this [name]test[/name] then I want to call a php function with the value "test" and grab all the info from my database and display that.

I noticed the same thing like you did it seems you an only use the value $1 directly in the construction so I was wondering if it was possible to get the value that $1 holds.

(I hope I made a little sense)