Link to Mod (http://mods.simplemachines.org/index.php?mod=510)
Rate this Mod (http://mods.simplemachines.org/index.php?action=review;sa=add;mod=510)
This mod will allow the use of [color] tags within [code] tags. It can be usefull when pointing out a specific change you made to some code.
Can you make a mod such that, certain groups can only use color codes n topic titles?
Quote from: nitins60 on October 25, 2006, 01:15:14 PM
Can you make a mod such that, certain groups can only use color codes n topic titles?
That is a completly different mod. And PMing me and posting about it twice isn't going to help you get it made.
Quote from: winrules on October 24, 2006, 04:58:21 PM
Link to Mod (http://mods.simplemachines.org/index.php?mod=510)
Rate this Mod (http://mods.simplemachines.org/index.php?action=review;sa=add;mod=510)
This mod will allow the use of [color] tags within [code] tags. It can be usefull when pointing out a specific change you made to some code.
I don't understand what this mod does?
If I change html code in an .php file am I enable to see what I've changed?
Where do I have to add the [color] tags? (around the changes?)
I am running 1.1 RC3, and I just installed this Mod. Unfortunately, it doesn't seem to be working properly.
If I try the following:
This is a test of [color=maroon]Color [/color]within Code
I end up with
[/color]within Code
The Mod said that it installed properly, and gave me no errors. Any idea what may be causing this?
Could I have a link to your site and a test account?
My site is found at http://www.ironcrown.com/ICEforums
Username: test
Password: testtest
Quote from: Rasyr on November 11, 2006, 01:34:12 PM
My site is found at http://www.ironcrown.com/ICEforums
Username: test
Password: testtest
Strange. Could you send my your Subs.php?
Great mod! Really makes it easy to describe certain things in code.
thanks
Nice mod. :)
Quote from: Rasyr on November 11, 2006, 10:11:51 AM
I am running 1.1 RC3, and I just installed this Mod. Unfortunately, it doesn't seem to be working properly.
If I try the following:
This is a test of [color=maroon]Color [/color]within Code
I end up with
[/color]within Code
The Mod said that it installed properly, and gave me no errors. Any idea what may be causing this?
I had the same problem (SMF1.1.2) but finally fixed it by making the following change. It looks like $count isn't incrementing as it should which is what caused the problem.
In Sources/Subs.php
foreach ($color_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(\'~\[color=(#[\da-fA-F]{3}|#[\da-fA-F]{6}|[A-Za-z]{1,12})\]~i\', \'<span style="color: $1;">\', $part, 1, $count);
$count = 0;
foreach ($color_parts as $id => $part)
{
$count++;
// 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(\'~\[color=(#[\da-fA-F]{3}|#[\da-fA-F]{6}|[A-Za-z]{1,12})\]~i\', \'<span style="color: $1;">\', $part);
But the above did not work when I used code=. Where the mod is written in the second time I discovered that $data needs to be changed to $data[0] as well.
// Mini-parser to parse just [color] tags.
if (!isset($disabled[\'color\']))
{
// Explode the data on each end tag.
$color_parts = explode(\'[/color]\', $data);
$last = count($color_parts) - 1;
$data = \'\';
foreach ($color_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(\'~\[color=(#[\da-fA-F]{3}|#[\da-fA-F]{6}|[A-Za-z]{1,12})\]~i\', \'<span style="color: $1;">\', $part, 1, $count);
// If we parsed the start tag we should also parse the end tag.
if ($count)
$data .= \'</span>\';
else
$data .= \'[/color]\';
}
// Else just add on the data.
else
$data .= $part;
}
}
// Older browsers are annoying, aren\'t they?
// Mini-parser to parse just [color] tags.
if (!isset($disabled[\'color\']))
{
// Explode the data on each end tag.
$color_parts = explode(\'[/color]\', $data[0]);
$last = count($color_parts) - 1;
$data[0] = \'\';
$count = 0;
foreach ($color_parts as $id => $part)
{
$count++;
// If it\'s not the last one, try to parse the tag and add it on to the data.
if ($id != $last)
{
$data[0] .= preg_replace(\'~\[color=(#[\da-fA-F]{3}|#[\da-fA-F]{6}|[A-Za-z]{1,12})\]~i\', \'<span style="color: $1;">\', $part);
// If we parsed the start tag we should also parse the end tag.
if ($count)
$data[0] .= \'</span>\';
else
$data[0] .= \'[/color]\';
}
// Else just add on the data.
else
$data[0] .= $part;
}
}
// Older browsers are annoying, aren\'t they?
Hope this helps. :)
Thanks, very useful mod and working on 1.1.9 8)
hi .. i am using this mod and its working good .. but its not work if we use color tags in capital e.g COLOR
how can i make this work ?
As I advised you in your other post, not without rewriting the mod from scratch.
Quote from: Rohan_ on August 29, 2009, 02:54:08 PM
hi .. i am using this mod and its working good .. but its not work if we use color tags in capital e.g COLOR
how can i make this work ?
Hi, it's been a while since i've looked at this but here's something to try.
Above
// Explode the data on each end tag.Add:
str_replace(array('[COLOR', 'COLOR]'), array('[color', 'color]'), $data);
If you're using the corrections I posted, for the second instance of the code array use
$data[0].
*nods* I was actually going to suggest that after I mentioned it elsewhere though I forgot about posting, thanks :)
Quote from: Kays on August 30, 2009, 11:49:25 AM
Quote from: Rohan_ on August 29, 2009, 02:54:08 PM
hi .. i am using this mod and its working good .. but its not work if we use color tags in capital e.g COLOR
how can i make this work ?
Hi, it's been a while since i've looked at this but here's something to try.
Above // Explode the data on each end tag.
Add:
str_replace(array('[COLOR', 'COLOR]'), array('[color', 'color]'), $data);
If you're using the corrections I posted, for the second instance of the code array use $data[0].
please tell me exactly that where i need to add this
Since you have the mod installed, look in Sources/Subs.php for // Explode the data on each end tag in two places.
Then add:
$data = str_replace(array('[COLOR', 'COLOR]'), array('[color', 'color]'), $data);
and
$data = str_replace(array('[COLOR', 'COLOR]'), array('[color', 'color]'), $data[0]);
Careful to ensure you add them the right way around.
where i need to add this ? do u mean
// Explode the data on each end tag.
$data = str_replace(array('[COLOR', 'COLOR]'), array('[color', 'color]'), $data);
$color_parts = explode(\'[/color]\', $data);
This ??
Yes.
Parse error: syntax error, unexpected '[' in /home/vhosts/www.site.com/Sources/Subs.php on line 1154
what happened ??? no reply ?
Sorry, I forgot that single quotes need to be escaped. Try this instead
str_replace(array(\'[COLOR\', \'COLOR]\'), array(\'[color\',\ 'color]\'), $data);
cant you tell the exact code what i need to replace with in a easy way ?? you saying to write direct str_replace and arantor saying $data = srt_replace ..
but none of them working .. where i need to add the code tell me exactly and now you are giving just 1 code what i need to add in second ?anyways this one also not works
Arantor 's correct, it should be:
$data = str_replace(array(\'[COLOR\', \'COLOR]\'), array(\'[color\',\ 'color]\'), $data);
and
$data[0] = str_replace(array(\'[COLOR\', \'COLOR]\'), array(\'[color\',\ 'color]\'), $data[0]);
Sorry, I don't know how I missed that.
And I don't know how I missed the fact it should have been escaped!
Quote from: Arantor on August 31, 2009, 05:06:43 AM
And I don't know how I missed the fact it should have been escaped!
it happens Bro :) let me try it
ok now i added the code . and it looks now like this
// Explode the data on each end tag.
$data = str_replace(array(\'[COLOR\', \'COLOR]\'), array(\'[color\',\ 'color]\'), $data);
$color_parts = explode(\'[/color]\', $data);
and
// Explode the data on each end tag.
$data[0] = str_replace(array(\'[COLOR\', \'COLOR]\'), array(\'[color\',\ 'color]\'), $data[0]);
$color_parts = explode(\'[/color]\', $data);
after uploading i got this
Parse error: syntax error, unexpected T_STRING in /home/vhosts/www.site.com/Sources/Subs.php on line 1156
Comment it out or remove it for now and attach Subs.php to a post.
here is my unedited subs.php
Try this. I've also added the corrections for code=xx
Do make a backup of your Subs.php before overwriting it. The code does work on my install, but I couldn't get your Subs.php to load on my install. Possibly a mod conflict.
THANKS A LOT . it worked . i was adding the code after // Explode the data on each end tag.
i also confirmed it before doing it .. but the problem was that i needed to add the code before // Explode the data on each end tag.
I've installed this and it is working even on 2.0 RC3 and 2.0 RC5 so no problems there. I have a small request... Is it possible to also do this for and tags?
My members are asking for it now that I enabled the color option haha
And what tags? If you mean the html tag, it's admin only for a very, very good reason.
Seriously, though, what is it with people abusing the code tag? It's for posting computer code, rarely needs colour formatting for that. If you need colour formatting, use something like tt which supports colours inside it naturally.
I know. I am not a big fan of it either, just wanted to know if it was possible for the people who ask for it