Changing category name color

Everything related to Hesk - helpdesk software

Moderator: mkoch227

Post Reply
fanta
Posts: 16
Joined: Wed Dec 16, 2009 11:00 am

Changing category name color

Post by fanta »

/*************************************
Title: Changing category name color
Version: 2

Short description:
I have used thispost to add the category name to the table on the admin home page, and it works great.

My question is, how can I set a different color to a specific category name in the table?
I tried wrapping the category name with <font color="red">New category</font> but that just printed out the font tag as well.

Thanks.
*************************************/

(Here below you can write additional info, longer description and comments)
Klemen
Site Admin
Posts: 10136
Joined: Fri Feb 11, 2005 4:04 pm

Post by Klemen »

That's because HTML tags are encoded for security. Try using something like

Code: Select all

$newcategory['name'] = preg_replace('/<font color="(.+)">(.*)<\/font>/','<font color="$1">$2</font>',$newcategory['name']);
before printing the category name (assuming you have the category name stored in $newcategory['name'] variable).
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
fanta
Posts: 16
Joined: Wed Dec 16, 2009 11:00 am

Post by fanta »

Thank you Klemen for your reply, but this change brings up a blank table.
What I want to achieve is to have my Category Name 1 in red color, not all categories. other categories should remain with the default color.

Thanks.
Klemen
Site Admin
Posts: 10136
Joined: Fri Feb 11, 2005 4:04 pm

Post by Klemen »

Post the exact code you use for printing the category name.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
fanta
Posts: 16
Joined: Wed Dec 16, 2009 11:00 am

Post by fanta »

This is the sql to fetch the category:

$sql = "SELECT * FROM `hesk_categories` WHERE `id`=$ticket[category] LIMIT 1";
$newresult = hesk_dbQuery($sql) or hesk_error("$hesklang[cant_sql]: $sql</p><p>$hesklang[mysql_said]:<br>".mysql_error()."</p><p>$hesklang[contact_webmsater] $hesk_settings[webmaster_mail]");
$newcategory = hesk_dbFetchAssoc($newresult);

This is the print category name:

<td class="$color">$newcategory[name]</td>

thanks for your help.
Klemen
Site Admin
Posts: 10136
Joined: Fri Feb 11, 2005 4:04 pm

Post by Klemen »

How about if you add something like

Code: Select all

if ($newcategory['name'] == 'Your category')
{
$newcategory['name'] = '<font color="red">'.$newcategory['name'].'</font>';
}
just below

Code: Select all

$newcategory = hesk_dbFetchAssoc($newresult); 
? Change 'Your category' to the exact name of your category (case sensitive).
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
fanta
Posts: 16
Joined: Wed Dec 16, 2009 11:00 am

Post by fanta »

Thank you Klemen, this works like a charm!
Post Reply