Community Forums

Color Single Category Text

Template support & advice for OpenCart v1.x

Color Single Category Text

Postby smorelli » Thu Aug 19, 2010 9:30 pm

Does anyone know how I can get a specific category to be styled? For instance, I have a CLEARANCE category that I would like in bold red. I don't see how I can add a style to that category.
Last edited by i2Paq on Fri Aug 20, 2010 8:21 am, edited 1 time in total.
Reason: Topic moved
smorelli
 
Posts: 93
Joined: Tue Jan 26, 2010 10:28 pm

Re: Color Single Category Text

Postby JAY6390 » Fri Aug 20, 2010 12:23 am

Open
Code: Select all
/catalog/controller/module/category.php

find
Code: Select all
$output .= '<li>'; 

around line 50 and change it to
Code: Select all
$output .= '<li id="category-'.$result['category_id'].'">'; 


then for say category 20, in your stylesheet use the selector
Code: Select all
#category-20 {
    /* STYLE INFO HERE */
}
ImageImageImage

Better Product SEO URL's - Perfectly structured product links
Better Category SEO URL's - Give subcategories the same SEO keyword
SEO URL's Route Editor - Fix all of your index.php links


Image
User avatar
JAY6390
 
Posts: 4636
Joined: Wed May 26, 2010 3:47 pm
Location: United Kingdom

Re: Color Single Category Text

Postby Maansy » Fri Aug 20, 2010 1:01 am

good info Jay :)
ALL Templates :: 1.5.1+ Templates :: 50%-75% PRICE DROP ONLY at OpencartStuff.com
User avatar
Maansy
 
Posts: 930
Joined: Wed Jun 23, 2010 10:04 pm

Re: Color Single Category Text

Postby smorelli » Fri Aug 20, 2010 2:11 pm

Excellent!!!!
smorelli
 
Posts: 93
Joined: Tue Jan 26, 2010 10:28 pm

Re: Color Single Category Text

Postby dramony » Tue Aug 24, 2010 5:10 am

is there a way where only the main category will be styled and not the sub-categories under it?
thanks!
User avatar
dramony
 
Posts: 258
Joined: Sat Oct 24, 2009 4:34 am

Re: Color Single Category Text

Postby JAY6390 » Tue Aug 24, 2010 11:18 am

Just use a child selector via css
http://www.w3.org/TR/CSS2/selector.html#child-selectors
for example, in the default theme, use
Code: Select all
#category > ul > li

which will only style the first level category list items, not their descendants.
ImageImageImage

Better Product SEO URL's - Perfectly structured product links
Better Category SEO URL's - Give subcategories the same SEO keyword
SEO URL's Route Editor - Fix all of your index.php links


Image
User avatar
JAY6390
 
Posts: 4636
Joined: Wed May 26, 2010 3:47 pm
Location: United Kingdom

Re: Color Single Category Text

Postby dramony » Tue Aug 24, 2010 12:44 pm

not working on my end..
User avatar
dramony
 
Posts: 258
Joined: Sat Oct 24, 2009 4:34 am

Re: Color Single Category Text

Postby JAY6390 » Tue Aug 24, 2010 1:26 pm

Not sure then with your stuff, but for example, on the category you can use
Code: Select all
#category > ul > li {
    border: 1px solid black;
}

and get this result
http://screenshots.jaygilford.com/2010-08-24_1425.png

If you want to edit the link tags, you need to use
Code: Select all
#category > ul > li > a
ImageImageImage

Better Product SEO URL's - Perfectly structured product links
Better Category SEO URL's - Give subcategories the same SEO keyword
SEO URL's Route Editor - Fix all of your index.php links


Image
User avatar
JAY6390
 
Posts: 4636
Joined: Wed May 26, 2010 3:47 pm
Location: United Kingdom

Re: Color Single Category Text

Postby dramony » Wed Aug 25, 2010 12:09 pm

Thank you Jay!

I used this code to make the parent category text to bold:
Code: Select all
#category > ul > li > a {
   font-weight:bold;
}
User avatar
dramony
 
Posts: 258
Joined: Sat Oct 24, 2009 4:34 am

Re: Color Single Category Text

Postby JAY6390 » Wed Aug 25, 2010 12:20 pm

Ah, figured it was the link not the li you wanted
ImageImageImage

Better Product SEO URL's - Perfectly structured product links
Better Category SEO URL's - Give subcategories the same SEO keyword
SEO URL's Route Editor - Fix all of your index.php links


Image
User avatar
JAY6390
 
Posts: 4636
Joined: Wed May 26, 2010 3:47 pm
Location: United Kingdom

Re: Color Single Category Text

Postby k2tec » Fri Mar 08, 2013 12:20 pm

I editted this line in my controller
Code: Select all
$output .= '<li id="category-'. $result['category_id'].'">';

and build in my CSS
Code: Select all
#category-21 {
   list-style: url('../image/twee.png');
   list-style-position:outside;
}

#category-21 li {
    background:#e9b447;
}


ect, etc. for the next categories

but my problem is that the image in front of my text is not centered
I also tried
Code: Select all
#category-20   {
   background: url('../image/een.png') center left no-repeat;   
}

but then the image is in my text.

does anyone have a solution to this problem
k2tec
 
Posts: 418
Joined: Mon Apr 12, 2010 12:06 pm


Return to Template Support

Who is online

Users browsing this forum: pwood, toejamm10 and 9 guests

Hosted by Arvixe Web Hosting