Post by yegga » Fri Sep 25, 2009 12:02 am

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.

Active Member

Posts

Joined
Tue Sep 08, 2009 5:03 am

Post by Qphoria » Fri Sep 25, 2009 12:16 am

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

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by yegga » Fri Sep 25, 2009 12:40 am

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?

Active Member

Posts

Joined
Tue Sep 08, 2009 5:03 am

Post by yegga » Fri Sep 25, 2009 12:43 am

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!

Active Member

Posts

Joined
Tue Sep 08, 2009 5:03 am

Post by Qphoria » Fri Sep 25, 2009 1:49 am

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

Code: Select all

#category.middle a{
     color: red;
}

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by yegga » Fri Sep 25, 2009 2:32 am

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?

Active Member

Posts

Joined
Tue Sep 08, 2009 5:03 am

Post by Qphoria » Fri Sep 25, 2009 3:20 am

Ah ok.. now I understand what you mean.

Not sure the best way for that one yet.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by yegga » Fri Oct 09, 2009 4:02 pm

ok, any way to make the 'main' categories as images, but the sub categories as text?

Active Member

Posts

Joined
Tue Sep 08, 2009 5:03 am

Post by fido-x » Fri Oct 09, 2009 10:39 pm

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).

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by fido-x » Fri Oct 09, 2009 10:50 pm

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.

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by imaginetech » Fri Oct 09, 2009 10:55 pm

Could this be done with css by using:-

.box .middle ul li li

And applyIng the desired style.
(haven't tested)

Image
www.opencartstore.com
Get OpenCart Templates and OpenCart Modules.


User avatar
Active Member

Posts

Joined
Fri Sep 04, 2009 12:25 pm
Location - Darwin, Australia

Post by fido-x » Fri Oct 09, 2009 11:07 pm

I hadn't thought about that. But it probably would work.

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by yegga » Sat Oct 10, 2009 5:15 pm

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?

Active Member

Posts

Joined
Tue Sep 08, 2009 5:03 am

Post by yegga » Sat Oct 10, 2009 5:25 pm

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="

?

Active Member

Posts

Joined
Tue Sep 08, 2009 5:03 am

Post by Qphoria » Thu Oct 15, 2009 4:24 am

Looks ok to me.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by fido-x » Thu Oct 15, 2009 9:13 am

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>';

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by yegga » Thu Oct 15, 2009 2:02 pm

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'

Active Member

Posts

Joined
Tue Sep 08, 2009 5:03 am

Post by dbstr » Thu Oct 15, 2009 5:30 pm

Try ((isset($style)) ? $style : '') instead of if (isset($style)) { echo $style; }

Request Reviews v1.0 released.


Active Member

Posts

Joined
Sun Aug 30, 2009 12:20 am

Post by yegga » Thu Oct 15, 2009 6:07 pm

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?

Active Member

Posts

Joined
Tue Sep 08, 2009 5:03 am

Post by yegga » Thu Oct 15, 2009 6:20 pm

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?

Active Member

Posts

Joined
Tue Sep 08, 2009 5:03 am
Who is online

Users browsing this forum: No registered users and 16 guests