Page 1 of 2
Different fonts for category module?
Posted: Fri Sep 25, 2009 12:02 am
by yegga
Hello, I would like to display all my categories with sub-categories in a different font size, smaller than the main category font size.
Is this possible? Do tell.
Re: Different fonts for category module?
Posted: Fri Sep 25, 2009 12:16 am
by Qphoria
edit the stylesheet.css file
add this to the bottom:
Code: Select all
#category.middle a{
font-size: 8pt;
}
change 8 to whatever you want
Re: Different fonts for category module?
Posted: Fri Sep 25, 2009 12:40 am
by yegga
nah qphoria that doesn't really do anything. i see no discernable changes at all!
help? can i make th emain categories a different color? and add a bullet or a tab-whitespace to the subcategories?
Re: Different fonts for category module?
Posted: Fri Sep 25, 2009 12:43 am
by yegga
the idea is to clearly distinguish between categories and sub-categories in a single glance, using font sizes. if you look at the category.tpl file in /module then you see that the class 'middle' applies to *ALL* things listed in the categories - this is not what I mean!
Re: Different fonts for category module?
Posted: Fri Sep 25, 2009 1:49 am
by Qphoria
My signifier of "#category" means that it will only apply to the category box. You will likely need to do Ctrl+F5 to refresh the browser cache
If you want different colors you can do
Re: Different fonts for category module?
Posted: Fri Sep 25, 2009 2:32 am
by yegga
i'm afraid i havent been clear enough:
in the category module, that lists all the categories and sub-categories, i would like to display the sub-categories in a different font than the parent categories. e.g:
Fruit
> Apples
> Bananas
Flowers
> Daisies
> Geraniums
Here I would like 'Apples' 'Bananas' 'Daisies' and 'Geraiums' in one font, say 8 px, and 'Fruit' and 'Flowers' in a larger font, say 12 px.
Qphoria, your suggestions result in a uniform font size being applied to both parent and child categories - so not really useful to my problem.
How do i do this?
Re: Different fonts for category module?
Posted: Fri Sep 25, 2009 3:20 am
by Qphoria
Ah ok.. now I understand what you mean.
Not sure the best way for that one yet.
Re: Different fonts for category module?
Posted: Fri Oct 09, 2009 4:02 pm
by yegga
ok, any way to make the 'main' categories as images, but the sub categories as text?
Re: Different fonts for category module?
Posted: Fri Oct 09, 2009 10:39 pm
by fido-x
In "catalog/controller/module/category.php", in the getCategories() function (lines 54 to 58), you'll find the following:-
Code: Select all
if ($this->category_id == $result['category_id']) {
$output .= '<a href="' . $this->model_tool_seo_url->rewrite($this->url->http('product/category&path=' . $new_path)) . '"><b>' . $result['name'] . '</b></a>';
} else {
$output .= '<a href="' . $this->model_tool_seo_url->rewrite($this->url->http('product/category&path=' . $new_path)) . '">' . $result['name'] . '</a>';
}
Just apply a bit of "style" to the anchor tag on lines 55 and 57, eg.
Code: Select all
<a style="font-size: smaller; color: #FF0000;">
(for a smaller red link).
Re: Different fonts for category module?
Posted: Fri Oct 09, 2009 10:50 pm
by fido-x
Follow up. The above code will apply to ALL categories, not just subcategories. A better way would probably be to insert the following:-
Code: Select all
if ($parent_id > 0) {
$style = 'style="font-size: smaller; color: #FF0000;"';
}
before line 54. Then in the anchor tag, use:
Code: Select all
<a <?php if (isset($style)) { echo $style; } ?> href=
This would then be applied to subcategories only.
Re: Different fonts for category module?
Posted: Fri Oct 09, 2009 10:55 pm
by imaginetech
Could this be done with css by using:-
.box .middle ul li li
And applyIng the desired style.
(haven't tested)
Re: Different fonts for category module?
Posted: Fri Oct 09, 2009 11:07 pm
by fido-x
I hadn't thought about that. But it probably would work.
Re: Different fonts for category module?
Posted: Sat Oct 10, 2009 5:15 pm
by yegga
if you were to do it with css as imaginetech suggests, would you insert the class in the catalog/controller/module/category.php into the anchor tags?
Re: Different fonts for category module?
Posted: Sat Oct 10, 2009 5:25 pm
by yegga
also fido: the updated code you posted displays the php within the anchor tag.
is the php placed right? should it be this way:
<a <?php if (isset($style)) { echo $style; } ?> href="
?
Re: Different fonts for category module?
Posted: Thu Oct 15, 2009 4:24 am
by Qphoria
Looks ok to me.
Re: Different fonts for category module?
Posted: Thu Oct 15, 2009 9:13 am
by fido-x
Qphoria wrote:Looks ok to me.
Thanks Q, but it is actually wrong. Normally, it would be OK but, in this instance, it's not. The reason being, that it is actually called from inside a PHP variable declaration. The full line should read-
Code: Select all
$output .= '<a ' . if (isset($style)) { echo $style; } . ' href="' . $this->model_tool_seo_url->rewrite($this->url->http('product/category&path=' . $new_path)) . '">' . $result['name'] . '</a>';
Re: Different fonts for category module?
Posted: Thu Oct 15, 2009 2:02 pm
by yegga
gentlemen:
the last bit of code by fido results in
'Parse error: syntax error, unexpected T_IF in /home/public/opencart/catalog/controller/module/category.php on line 60'
Re: Different fonts for category module?
Posted: Thu Oct 15, 2009 5:30 pm
by dbstr
Try ((isset($style)) ? $style : '') instead of if (isset($style)) { echo $style; }
Re: Different fonts for category module?
Posted: Thu Oct 15, 2009 6:07 pm
by yegga
gentlemen: this works. dbstr's solution works.
however: how do i apply this to sub-sub categories ad infinitum?
right now this applies a style to only categories one level deeper than the main categories.
but i have say, 4 levels of nested categories - how do i style them all?
Re: Different fonts for category module?
Posted: Thu Oct 15, 2009 6:20 pm
by yegga
right now, if i click on a parent category, the parent category is bold,
and if i click on a sub category, the sub category is bold but not the parent
how do i style it so that if i click a subcategory, BOTH sub and parent category are bold?