php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #59695 Callback for handling BBCode Tags
Submitted: 2011-03-29 07:27 UTC Modified: 2011-03-29 08:41 UTC
From: harald dot lapp at gmail dot com Assigned:
Status: Closed Package: bbcode (PECL)
PHP Version: 5.3.5 OS: linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: harald dot lapp at gmail dot com
New email:
PHP Version: OS:

 

 [2011-03-29 07:27 UTC] harald dot lapp at gmail dot com
Description:
------------
It would be very nice, if you could specify a callback for 
bbcode tags. This would be very useful for example for a forum 
etc. where you add a post-id as argument for the "quote" tag.

With a callback you could handle the argument and fetch 
further information of the quoted text, e.g.: author-name etc.


Reproduce code:
---------------
<?php

$string = <<<EOT
[quote=1234]
some-quoted-text
[/quote]

some more text
EOT;

$bbcode = array(
    ''  => array(
        'type' => BBCODE_TYPE_ROOT
    ),
    'quote' => array(
        'type'     => BBCODE_TYPE_OPTARG, 
        'open_tag' => function(arg) {
            // do some stuff here like DB lookups etc, to get additional information for specified argument
            return "<blockquote><a href="...">" . $author_name . "</a></blockquote><br />";
        },
        'close_tag' => '</blockquote>'
    )
);

$bbhandler = bbcode_create($bbcode);
bbcode_parse($bbh, $string);

?>

Expected result:
----------------
<blockquote><a href="...">author_name</a><br />
some-quoted-text
</blockquote>

some more text



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-03-29 08:41 UTC] xdecock at gmail dot com
Thank you for your bug report. This issue has been fixed
in the latest released version of the package, which you can download at
http://pecl.php.net/get/bbcode

The content And param handlers already work this way, I don't see the point. Callbacks are already implemented altough not this way...

Check this page. http://be.php.net/manual/en/function.bbcode-create.php
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue May 13 10:01:27 2025 UTC