Code Block witth BBCode

Started by Hondo, January 01, 2014, 07:50:17 AM

Previous topic - Next topic

Hondo

I want that Textformating works inside a Code Block. EG for highlighting text wich is not correct or so.
So I need only Bold, Underline, Fontsize and Fontcolor.
How can I do this? Where is the position where the bbcode is create in a posting?
For example:
[color=red]Test[/color]

Andreas

Kays

Hi, here's a mod for 1.1 which will allow the used of the bbc color tag. Although it probably won't install on 2.0 the code changes are still valid. So use this as a guide. :)

http://custom.simplemachines.org/mods/index.php?mod=510

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Hondo

Danke,
hat funktioniert, habs manuell geändert, war ja nicht so viel.
Gruß Andreas

Kays


If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Hondo

Oh I'm so sorry, I forgot that I'm on english support board.
Yes modification works, I had to modify it by hand but it just was easy.
Thanks
Andreas

Kays

Cool, one thing though. There are two blocks for the code tag. The edits for the second block are the same as the first except that you'll need change $data to $data[0].

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Hondo

Yes, thanks.

But now I want to try to made the same with the size-tag. Here is my try:

if (!isset($disabled[\'size\']))
{
// Explode the data on each end tag.
$size_parts = explode(\'[/size]\', $data);

$last = count($size_parts)- 1;
$data = \'\';

foreach ($size_parts as $id => $part)
{
// If it's not the last one, try to parse the tag and add it on to the data.
if ($id != $last)
{
$data .= preg_replace(\'~\[size=(.*)\]~i\', \'<span style="font-size: $1;" class="bbc_size">\', $part, 1, $count);
// If we parsed the start tag we should also parse the end tag.
if ($count)
$data .= \'</span>\';
else
$data .= \'[/size]\';
}
// Else just add on the data.
else
$data .= $part;
}
}


Testet on a local-File and it is working: http://www.access-o-mania.de/test.php
But inserted to subs.php I only get a white Screen without code.
Where is the problem?

Hondo

OK got it, here is my solution:

// Mini-parser to parse just [size] tags.
if (!isset($disabled[\'size\']))
{
// Explode the data on each end tag.
$size_parts = explode(\'[/size]\', $data);

$last = count($size_parts) - 1;
$data = \'\';

foreach ($size_parts as $id => $part)
{
// If it\'s not the last one, try to parse the tag and add it on to the data.
if ($id != $last)
{
$data .= preg_replace(\'~\[size=([A-Za-z0-9]{1,12})\]~i\', \'<span style="font-size: $1;" class="bbc_size">\', $part, 1, $count);

// If we parsed the start tag we should also parse the end tag.
if ($count)
$data .= \'</span>\';
else
$data .= \'[/size]\';
}
// Else just add on the data.
else
$data .= $part;
}
}


Thanks
Andreas

Advertisement: