Adding New BBcode Tags »  Show posts from    to     

Icy Phoenix


Old Customizations - Adding New BBcode Tags



glenflet [ Sat 27 Sep, 2008 06:55 ]
Post subject: Adding New BBcode Tags
Ok now that I've got my code 2 html BBcode working,
I would like to try adding some whole new BBcode tags, to use a few Java functions for some cool text effects.

Could some one explain what I need to do to define new BBcode tags.


Lopalong [ Sun 28 Sep, 2008 02:13 ]
Post subject: Re: Adding New BBcode Tags
You should be able to find that in the docs section - And it's a whole lot different from the usual way of doing it. ;)


glenflet [ Sun 28 Sep, 2008 06:34 ]
Post subject: Re: Adding New BBcode Tags
Lopalong wrote: [View Post]
You should be able to find that in the docs section - And it's a whole lot different from the usual way of doing it. ;)


I had a look there, but could find any thing about how to add the new tags.

Can you provide a direct link to the topic please.

Edit: I would also like to replace phpBB3 BBcode, with Icy Phoenix BBcode, as phpBB 3 is to hard to modify to my own needs, any suggestions on how I should go about this?


Lopalong [ Sun 28 Sep, 2008 08:09 ]
Post subject: Re: Adding New BBcode Tags
You're right mate, difficult to locate for the uninitiated. ;)

There's a lot of work being done on docs now - but that's not going to help short-term. :(

Though this should help.

http://www.icyphoenix.com/viewtopic...&p=29850#p29850


glenflet [ Sun 28 Sep, 2008 08:28 ]
Post subject: Re: Adding New BBcode Tags
I had a look at that topic, but I don't see how that tells, me how to add ne BBcode tags.

I've got some javascript I want to use with BBcode.

i.e.
Code: [Hide] [Select]
<script language="javascript">
var text = "Hello World!"
var speed = 80
rainbow()
</script>


Where the BBcode would be
Code: [Hide] [Select]
[rainbow speed=80]Hello World![/rainbow]


i.e.
Code: [Hide] [Select]
<script language="javascript">
var text = "Hello World!"
var speed = 80
var basecolor = "#808080"
var textcolor = "#00ffff"
neonText()
</script>


Where the BBcode would be
Code: [Hide] [Select]
[neon speed=80 basecolor=128,128,128 textcolor=0,255,255]Hello World![/neon]


I also want to rename the existing rainbow to gradient.

I can make the php to generate the HTML output just fine, it just how to add the tags to the BBcode that I can't do, and how to tell it what variable I'm look for, to cofirm I understant that propely.


Lopalong [ Sun 28 Sep, 2008 08:56 ]
Post subject: Re: Adding New BBcode Tags
:mrviolet:

This is an unreleased MOD that I've done for the next version of IP (Though it's basically the same) and it should contain all of the examples you need - Plus put you in the right places to compare other bbCode entries that switch other params as well. ;)

And this example adds a url option - You only want simple tags. :)

Spoiler: [ Show ]


Mighty Gorgon [ Sun 28 Sep, 2008 11:59 ]
Post subject: Re: Adding New BBcode Tags
You need to add the tag into this array: var $allowed_bbcode = array (follow what has been done for others...)

Then you need to add the IF statement into the function process_tag(&$item) adding the HTML you want to output.

That should be enough for your BBCode to work.


glenflet [ Mon 29 Sep, 2008 04:48 ]
Post subject: Re: Adding New BBcode Tags
Ok,I've got the BBcode working now, thanks for the help

How to Add Rainbow and Neon Text

EXTRACT texteffects.zip to templates/common/js

OPEN includes/bbcode.php
FIND
Code: [Hide] [Select]
'rainbow' => array(
'nested' => true,
'inurl' => true,
'allow_empty' => false,
),

REPLACE WITH
Code: [Hide] [Select]
'gradient' => array(
'nested' => true,
'inurl' => true,
'allow_empty' => false,
),

ADD AFTER
Code: [Hide] [Select]
'neon' => array(
'nested' => false,
'inurl' => false,
),
'rainbow' => array(
'nested' => false,
'inurl' => false,
),

FIND
Code: [Hide] [Select]
// RAINBOW
if($tag === 'rainbow')
{
/*
if($this->is_sig)
{
return $error;
}
*/
$html = rainbow($content);
return array(
'valid' => true,
'html' => $html,
'allow_nested' => false,
);
}

REPLACE WITH
Code: [Hide] [Select]
// GRADIENT
if($tag === 'gradient')
{
/*
if($this->is_sig)
{
return $error;
}
*/
$html = rainbow($content);
return array(
'valid' => true,
'html' => $html,
'allow_nested' => false,
);
}

ADD AFTER
Code: [Hide] [Select]
// RAINBOW
if($tag === 'rainbow')
{
/*if($this->is_sig)
{
return $error;
}*/
$speed = 80;
if(isset($item['params']['speed']))
{
try
{
$speed = intval($item['params']['speed']);
} catch (Exception $e) {
break;
}
}
$text = $content;
if(strpos($text,"n") !== false)
{
return $error;
}
$html = "n<script language="javascript" type="text/javascript">nvar text = "". $text . ""nvar speed = " . $speed . " nrainbow()n</script>n<noscript>" . $text . "</noscript>n";
return array(
'valid' => true,
'html' => $html,
);
}

// NEON
if($tag === 'neon')
{
/*if($this->is_sig)
{
return $error;
}*/
$speed = 80;
if(isset($item['params']['speed']))
{
try
{
$speed = intval($item['params']['speed']);
} catch (Exception $e) {
break;
}
}
$colors = array();
$red = 128;
$green = 128;
$blue = 128;
if(isset($item['params']['basecolor']))
{
try
{
$colors = split(",",$item['params']['basecolor']);
for($i=0;$i<3;$i++)
{
if (intval($colors[$i]) > 255)
{
$colors[$i] = "255";
}
elseif (intval($colors[$i]) < 0)
{
$colors[$i] = "0";
}
}
$red = intval($colors[0]);
$green = intval($colors[1]);
$blue = intval($colors[2]);
} catch (Exception $e) {
break;
}
}
$basecolor = "rgb(" . $red . ", " . $green . ", " . $blue . ")";
$red = 64;
$green = 64;
$blue = 255;
if(isset($item['params']['textcolor']))
{
try
{
$colors = split(",",$item['params']['textcolor']);
for($i=0;$i<3;$i++)
{
if (intval($colors[$i]) > 255)
{
$colors[$i] = "255";
}
elseif (intval($colors[$i]) < 0)
{
$colors[$i] = "0";
}
}
$red = intval($colors[0]);
$green = intval($colors[1]);
$blue = intval($colors[2]);
} catch (Exception $e) {
break;
}
}
$textcolor = "rgb(" . $red . ", " . $green . ", " . $blue . ")";
$text = $content;
if(strpos($text,"n") !== false)
{
return $error;
}
$html = "n<script language="javascript" type="text/javascript">nvar text = "". $text . ""nvar speed = " . $speed . " nvar basecolor = "" . $basecolor . ""nvar textcolor = "" . $textcolor . ""nneon()n</script>n<noscript>" . $text . "</noscript>n";
return array(
'valid' => true,
'html' => $html,
);
}


OPEN templates/mg_themes/overall_include.tpl
FIND
Code: [Hide] [Select]
{UPI2DB_FIRST_USE}

ADD BEFORE
Code: [Hide] [Select]
<script type="text/javascript" src="{FULL_SITE_PATH}{T_COMMON_TPL_PATH}js/texteffects.js"></script>


NOTE: If you have other base template, You'll need to modify them as well.

BBcode Info
Key
{optional=Defualt Value}
required=Format

Neon
Highlight letter by letter at given speed, stays lit for a bit thte restarts.
Code: [Hide] [Select]
[neon {speed=80} {basecolor=128,128,128} {textcolor=0,0,255}]Text here[/neon]


Rainbow
Text changes colour at given speed
Code: [Hide] [Select]
[rainbow {speed=80}]Text here[/neon]


NOTE: the old rainbow is now gradient




Powered by Icy Phoenix