Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

[Solved][2.1b2] Need help replacing specific text with icon

ZhaanZhaan ✭✭
edited December 2013 in Vanilla 2.0 - 2.8

Good evening, VF. :)

So here's my problem today: I want to replace the 'Announcement' and 'Closed' status text with icons (using Font Awesome), but I'm not sure which templates to edit. Could someone point me in the right direction?

Thanks in advance!

Comments

  • KasperKasper Vanilla Staff

    To get things going, put the following in {your-theme}/views/discussions/helper_functions.php:

    <?php if (!defined('APPLICATION')) exit;
    
    if (!function_exists('Tag')):
        function Tag($Discussion, $Column, $Code, $CssClass = FALSE) {
            $Discussion = (object)$Discussion;
    
            if (is_numeric($Discussion->$Column) && !$Discussion->$Column)
                return '';
            if (!is_numeric($Discussion->$Column) && strcasecmp($Discussion->$Column, $Code) != 0)
                return;
    
            if (!$CssClass)
                $CssClass = "Tag-$Code";
    
            $Icons = array(
                'Tag-Closed' => 'foo',
                'Tag-Announcement' => 'bar'
            );
    
            if (isset($Icons[$CssClass])) $Icon = $Icons[$CssClass];
    
            return ' <span class="Tag '.$CssClass.'" title="'.htmlspecialchars(T($Code)).'">'.(isset($Icon)) ? '<i class="fa fa-'.$Icon.'"></i>' : T($Code).'</span> ';
        }
    endif;
    
    require_once PATH_APPLICATIONS . '/vanilla/views/discussions/helper_functions.php';
    

    Kasper Kronborg Isager (kasperisager) | Freelance Developer @Vanilla | Hit me up: Google Mail or Vanilla Mail | Find me on GitHub

  • Thanks a lot! I'll give it a try.

  • Turns out my coding knowledge is worse than I thought! What else do I need to do here? :P

  • I would try and use a definition for 'Announcement' and 'Closed' that has a sprite span.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • Hadn't though of that. Will try!

  • Oh wow, that did work. How brilliant!

Sign In or Register to comment.