Post by inets » Tue Jun 17, 2008 12:31 am

I want to set another color on category link when category is active.
Does anyone can help me?

Newbie

Posts

Joined
Thu Sep 20, 2007 3:50 am

Post by lev » Tue Jun 17, 2008 1:12 am

where?

ex /index.php?controller=home
  or /index.php?controller=category

lev
New member

Posts

Joined
Wed Apr 30, 2008 10:47 pm

Post by Luvz2drv » Tue Jun 17, 2008 6:14 am

most likely wants it for the cat module

Global Moderator

Posts

Joined
Fri Mar 21, 2008 10:58 am

Post by fido-x » Sat Jun 28, 2008 1:11 am

Do you mean something like http://www.fido-x.net/demostore/?

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 inets » Thu Nov 13, 2008 4:27 pm

I try this example, but its dont work.

category/controller/category.php
---------------------------------------------
  $request  =& $this->locator->get('request');
    if ($config->get('category_status')) {
    $selected = $request->get('path');
    }   

....
                      $category_data[] = array(
                        'selected' => ($selected == $result['category_id']),
....
catalog/template/module/category.tpl
-------------------------------------------
' . $category['name'] . '';
else
    echo '' . $category['name'] . '!';
    } ?>


After I set in category.php test variable in array like     'a' => "aaa", and echo it in category.tpl like   echo $category[a]; I have this error:
Undefined index: a

I think its is the same problem because when I try to echo selected same error.

Can anyone help me?
Last edited by inets on Thu Nov 13, 2008 5:06 pm, edited 1 time in total.

Newbie

Posts

Joined
Thu Sep 20, 2007 3:50 am

Post by fido-x » Thu Nov 13, 2008 5:15 pm

OK. Here we go, giving away trade secrets.

In "catalog/extension/module/category.php" insert the following (around line 20 in 0.7.9RC3):-

Code: Select all

// active state inserted by Fido-X
if ($request->get('controller') == 'category') {
   if ($request->get('path') == $result['path']) {
      $state = 'active';
   } else {
      $state = 'inactive';
   }
} else {
   $state = 'inactive';
}
// end of insert
foreach ($results as $result) {
   $category_data[$result['category_id']] = array(
      // active state inserted by Fido-X
      'state' => $state,
      // end of insert
In "catalog/template/default/css/default.css", look for (around line 331)-

Code: Select all

.box .category a {
   background: url('../image/bullet_1.png') no-repeat 15px 5px;
   padding: 0px 0px 0px 25px;
   display: block;
   text-decoration: none;
   margin-bottom: 8px;
}
and add after this-

Code: Select all

/* active class inserted by Fido-X */
.box .category a.active {
   background: url('../image/bullet_1.png') no-repeat 15px 5px;
   padding: 0px 0px 0px 25px;
   display: block;
   text-decoration: none;
   margin-bottom: 8px;
   color: #0000FF; // set color to whatever you want in this case blue
}
/* end of insert */
Then, in "catalog/template/default/module/category.tpl", change_

Code: Select all

<a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a>
to

Code: Select all

<a class="<?php echo $category['state']; ?>" href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a>
This should give you an "active state" for your category links. Do the same in your information files for the same effect.

Fido-X.

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
Who is online

Users browsing this forum: No registered users and 2 guests