Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Oct 2003
    Location
    Australia
    Posts
    112
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Disable smiley in code

    Hi

    I'm coding a forum and would like to disable smilies in between the [ code ] string. Problem is that I have 2 arrays that do the smiley and formatting functions but I can't seem to modify the function to insert the code check in.

    Code:
    $codes = array(
    "\n" => "<br />",
    
    '' => '<b>',
    '' => '</b>',
    '' => '<i>',
    '' => '</i>',
    
    '' => '<u>',
    '' => '</u>',
    
    '[ol]' => '<ol>',
    '[/ol]' => '</ol>',
    '[li]' => '<li>',
    '[/li]' => '</li>',
    
    '[ul]' => '<ul>',
    '[/ul]' => '</ul>',
    '
    Code:
    ' => '<div class="code">',
    '
    ' => '</div>', '[c]' => '<center>', '[/c]' => '</center>', '[s]' => '<strike>', '[/s]' => '</strike>', '
    ' => '<div class="quote">', '
    ' => '</div>' ); $smilies = array( ':)' => 'smile.gif', ':smile:' => 'smile.gif', ':cool:' => 'cool.gif', ':grin:' => 'vhappy.gif', ':D' => 'vhappy.gif', ':sad:' => 'sad.gif', ':wink:' => 'wink.gif', ':b' => 'tounge.gif', ':p' => 'tounge.gif', ':mad:' => 'mad.gif', ':evil:' => 'evil.gif', ':pirate:' => 'pirate.gif', ':grrr:' => 'grrr.png', ':dead:' => 'dead.png', ':wtf:' => 'wtf.png', ':sweat:' => 'llsweatdrop.gif', ':day:' => 'bday.gif', ':lol:' => 'lol.gif', ':cry:' => 'cry.gif', ':bla:' => 'bla.gif', ':o.o:' => 'oO.gif', ':zz:' => 'sleep.gif', ':err:' => 'err.png', ':sleep:' => 'sleep.gif', ':psh:' => 'psh.png', ':shock:' => 'shock.png', ':@.@' => 'twitch.gif', ':ship:' => 'ship.gif', ':love:' => 'love.gif', ':hammer:' => 'hammer.gif', ':Blush' => 'blush.gif', ':clap:' => 'clapping.gif', ':hug:' => 'hug.gif' ); foreach($codes as $code=>$html) { $tr_entry = str_replace($code, $html, $tr_entry); } foreach($smilies as $smile=>$image) { $tr_entry = str_replace($smile, "<img src=\"smilies/$image\">", $tr_entry); $tr_entry = str_replace("$#39;","'", $tr_entry); }
    can someone enlighten me? thanks for the trouble.

  • #2
    Regular Coder
    Join Date
    Sep 2002
    Location
    Scotland
    Posts
    407
    Thanks
    0
    Thanked 0 Times in 0 Posts
    why not set a variable $code=1 whenever the {code} tag is opened, then set $code=0 when the {/code} tag is closed.

    Then put an IF statement on the function that prints the smileys that only allows them to be displayed if $code=0
    My body's a temple... and like those ancient Greek ones it's a ruin
    sweenster.co.uk

  • #3
    Regular Coder
    Join Date
    Oct 2003
    Location
    Australia
    Posts
    112
    Thanks
    0
    Thanked 0 Times in 0 Posts
    do I use regex to look for {code} or I edit the function array to set
    PHP Code:
    '[code]' => '$code=1'
    instead? Thanks for helping.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •