News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Use [color] Tags in [code] Mod

Started by winrules, October 24, 2006, 04:58:21 PM

Previous topic - Next topic

Rohan_

Parse error: syntax error, unexpected '[' in /home/vhosts/www.site.com/Sources/Subs.php on line 1154
Proud To Be An Indian

Rohan_

Proud To Be An Indian

Kays

Sorry, I forgot that single quotes need to be escaped. Try this instead



str_replace(array(\'[COLOR\', \'COLOR]\'), array(\'[color\',\ 'color]\'), $data);

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

Rohan_

#23
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
Proud To Be An Indian

Kays

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.

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

Arantor

And I don't know how I missed the fact it should have been escaped!

Rohan_

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
Proud To Be An Indian

Rohan_

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
Proud To Be An Indian

Kays

Comment it out or remove it for now and attach Subs.php to a post.

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

Rohan_

Proud To Be An Indian

Kays

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.

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

Rohan_

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.

Proud To Be An Indian

devoetbalkantine

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

Arantor

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.

devoetbalkantine

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

Advertisement: