[Resolved 2.4.0] Remove colour codes from hashtags

Hi guys, will you ever remove the colour codes from hashtags. The preg_match below searches for a three and six character hex code starting with a number sign and removes it from the list. I'm sure we could just do something like this in the next update, before it is shown in the div elements [Tags] and [Popular Tags].
 
The code below has been tested on #247BBA #333 #ccc colour codes.
 
Problem solved for tags
 
Edit this file:-
 
\app\View\Widgets\core
 
tags.ctp

 Copy and paste over line 58 with this code below to solve the colour code issue:-
 
       <?php //Check for any hex color string '#247BBA', '#333', '#ccc'
            $colorCodes = h($tag);
            if (preg_match('/^[a-f0-9]{3}$/i', $colorCodes) || preg_match('/^[a-f0-9]{6}$/i', $colorCodes)) //hex color is valid
            { echo ''; //Verified hex color do nothing
                } else {
            ?>
            <li><a href="<?php echo $this->request->base?>/search/hashtags/<?php echo h($tag)?>/tabs:<?php echo $type; ?>"><?php echo h($tag)?></a></li>
        <?php }    ?>

Try it!
 
 
Posted in v2.3.0 Bug Reports on 02/12/16 at 22:25
Comments (15)
Eddie  
Ryan Nguyen, the above code has resolved the issuse - Try it!
Thanks, Eddie! We will review and see what we could do with this. - mooTechnicalTeam
This has been resolved in 2.4.0.
Eddie  
Hi guys - mooSupport, has this been include in the newer versions? As it is not working here! lol

P.S. - I have not tested in ver.2.4.1 yet
As Ryan Nguyen said, it is fixed on 2.4.1
Eddie  
Maybe on the Tags side widget but not on the Popular Tags lol

With mooSupport.

Hi Eddie,
Thanks for you report we will review and fix it on next version.
Thanks,
Kent,
Layla  
Eddie you're on the right way, but I think it should be different... Because #911 will also be detected as "collor code" but it isn't, you better can change regex to "color: #[a-fA-F0-9]{3,6}$...." or am I wrong?

Be sure the hexcode which will be ignored is defined after color="#XXX or "color: #XXX; (style).

In short make a regex which can detect and ignore #ff00ff and #ff0000: but keep hashtag #666

<span style="color: #ff00ff; background-color: #ff0000;">#666</span>
Layla  
What about skipping color codes by:

/(color:[" "]{0,1}|color=["']{0,1})#[a-f0-9]{3,6}/i
Layla  
This one is cleaner

/(color[":="]{1}[" "]{0,1}["']{0,1})#[a-f0-9]{3,6}/i
Layla  
Eddie I don't see this bug in 2.4.1, I think the codes are still shown up because of upgrade, I have a clean install and no problem at all
No login
Login or register to post your comment
Cookies on mooCommunity - Social Networking Script.
This site uses cookies to store your information on your computer.