Welcome Guest, Not a member yet? Register   Sign In
NBBC Callback Tags + CI

Ok guys so here is my problem,
I got my forum, I need bbcode's for it.
I found a good system for BBcodes called "NBBC" feel free to google it,
So my problem is that there are Callback Tags,
They give ability to do function's.
Sadly when I tried to combine my CI code and this NBBC system
It just broke the code in half way...
So any help guys?

Ps. Also I am sorry I am asking so many questions and so often Smile
I am just learning Tongue

Someone else found out how to use NBBC with CodeIgniter :


If you can't get it to work, there are some BBCode helpers out there :


Good luck Wink

The problem is that Callback's must have the function's in global namespace...
Library's have a class... CI seem to work only in its library class...
any way to make CI function outside of namespace?

been five hours now, none wants to tell me how to add CI functional into
global namespace...

<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

require_once 'bb/nbbc_main.php';

function MyBorderFunction($bbcode, $action, $name,    $default, $params, $content) {
    if ($action == BBCODE_CHECK) {
        if (isset($params['color'])
            && !preg_match('/^#[0-9a-fA-F]+|[a-zA-Z]+$/', $params['color']))
            return false;
        if (isset($params['size'])
            && !preg_match('/^[1-9][0-9]*$/', $params['size']))
            return false;
        return true;

    $color = isset($params['color']) ? $params['color'] : "blue";
    $size = isset($params['size']) ? $params['size'] : 1;
    return "<div {$size}px solid $color\">$content</div>";

function MyMCFunction($bbcode, $action, $name,    $default, $params, $content) {
    if ($action == BBCODE_CHECK) {
        if (isset($params['name'])
            && !preg_match('/^[a-zA-Z0-9]+$/', $params['name']))
            return false;
        return true;

   // $name = isset($params['name']) ? $params['name'] : "char";
   // $name = isset($default) ? $default : $params['name'];
   $this_test = $this->CI->access->hashPass("lol");
$site = site_url('mc/'.$content);
    return "<img >";

class Mybbcode
var $CI;

function Mybbcode()
  $this->CI =& get_instance();

function dowork($content = "NoBBCodeContent",$type = "basic")

$user = $this->CI->access->get_user();
$bbcode = new BBCode;
$bbcode->AddRule('viewer_name',  Array(
        'simple_start' => "{$user->screen_name}",
        'simple_end' => '',
        'class' => 'inline',
        'allow_in' => Array('listitem', 'block', 'columns', 'inline', 'link'),
$bbcode->AddRule('border',  Array(
        'mode' => BBCODE_MODE_CALLBACK,
        'method' => 'MyBorderFunction',
        'class' => 'block',
        'allow_in' => Array('listitem', 'block', 'columns'),
$bbcode->AddRule('mc',  Array(
        'mode' => BBCODE_MODE_CALLBACK,
        'method' => 'MyMCFunction',
        'class' => 'block',
        'allow_in' => Array('listitem', 'block', 'columns', 'inline', 'link'),
$bbcode->AddRule('viewer_id',  Array(
        'simple_start' => "{$user->id}",
        'simple_end' => '',
        'class' => 'inline',
        'allow_in' => Array('listitem', 'block', 'columns', 'inline', 'link'),
    return $bbcode->Parse($content);

Ok here is the code of what I got so far,
there is a test variable in MC function, its just there to see if It would work or not,
what I basicly need is ability to interct with the rest of the CI outside from a function like that MC func...
any help?
ps. going sleep now, hope for some help tomorow...

So yeah I figured it out on my own, as always -.-...
Thanks for nothing.

[quote author="nagata" date="1341554597"]So yeah I figured it out on my own, as always -.-...
Thanks for nothing.[/quote]

Since you always figure it out on your own anyway, why didn't you just work a little harder till you got it this time, instead of ruining your reputation on this forum by acting like a complete jerk?

No one here owes you anything. We offer help for FREE when we have the time and some idea of what the problem might be.

Yeah sorry, its just I waited for a whole day hoping for some solution, and none helped....
Also I solved the problem by calling my
Library called "Mybbcode" right from the function, like this
Is someone was wondering...

Theme © iAndrew 2016 - Forum software by © MyBB