Post by simonishvilii » Thu Aug 07, 2014 1:20 am

hello.. I am new with opencart and it seems a bit hard than joomla cms. in joomla each menu item has its own class and it`s very easy to change any menu item style (color, font-size...). In opencart I also want to add different class to every menu item but i have no idea how to do it. Can anyone help me??

Newbie

Posts

Joined
Thu Aug 07, 2014 1:16 am

Post by simonishvilii » Sat Aug 30, 2014 12:51 am

No any ideas?? :(

Newbie

Posts

Joined
Thu Aug 07, 2014 1:16 am

Post by Dhaupin » Sat Aug 30, 2014 1:29 am

You can use the category ID for this. Here is an example VQ snippet that works with default OC (wont work with multi level dropdown mod). This will add a class "cat-654" or whatever the category ID is in the top menu bar:

Code: Select all

<modification>

	<id><![CDATA[Adds CSS classes to categories in header.]]></id>
	<version><![CDATA[1.0.0]]></version>
	<vqmver><![CDATA[2.4.1]]></vqmver>
	<author><![CDATA[CreadevDotOrg]]></author>

	<file name="catalog/controller/common/header.php">

		<operation error="log">
			<search position="after"><![CDATA[
				'name'  => $child['name'] . ($this->config->get('config_product_count') ? ' (' . $product_total . ')' : ''),
			]]></search>
			<add><![CDATA[
						'child_id' => $child['category_id'],
			]]></add>
		</operation>
		<operation error="log">
			<search position="after"><![CDATA[
				'name'     => $category['name'],
			]]></search>
			<add><![CDATA[
					'category_id' => $category['category_id'],
			]]></add>
		</operation>

	</file>

	<file name="catalog/view/theme/*/template/common/header.tpl">

		<operation error="log">
			<search position="replace"><![CDATA[
				<li><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a>
			]]></search>
			<add><![CDATA[
    <li class="cat-<?php echo $category['category_id']; ?>"><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a>
			]]></add>
		</operation>
		<operation error="log">
			<search position="replace"><![CDATA[
				<li><a href="<?php echo $category['children'][$i]['href']; ?>"><?php echo $category['children'][$i]['name']; ?></a></li>
			]]></search>
			<add><![CDATA[
          <li class="cat-<?php echo $category['children'][$i]['child_id']; ?>"><a href="<?php echo $category['children'][$i]['href']; ?>"><?php echo $category['children'][$i]['name']; ?></a></li>
			]]></add>
		</operation>

	</file>

</modification>

You can also just use CSS based on the menu link without extra classes. Lets say you had a category item that was pointing to http://www.example.com/widgets here is the css that would control all menu items containing "/widgets" in the url and make them huge font:

Code: Select all

#menu [href$="/widgets"] {
	font-size: 2em;
}

https://creadev.org | support@creadev.org - Opencart Extensions, Integrations, & Development. Made in the USA.


User avatar
Active Member

Posts

Joined
Tue May 13, 2014 3:45 am
Location - PA
Who is online

Users browsing this forum: No registered users and 44 guests