I have made some cosmetic changes in the top menu bar and now I would somebody to please help me out with a small problem that I face. Please see the image below.
I want that, after the user selects a "category"(shown in red box above) that selected "category" should remain highlighted even after the mouse has been moved away so that the user comes to know what "category" he has selected.
I hope I have explained it clearly. Can someone please show or guide me how to do this.
Thank You for your time.
I want that, after the user selects a "category"(shown in red box above) that selected "category" should remain highlighted even after the mouse has been moved away so that the user comes to know what "category" he has selected.
I hope I have explained it clearly. Can someone please show or guide me how to do this.
Thank You for your time.
Regards,
Sun Systems
Industrial Electronics and Instrumentation
I can offer you only quick & dirty solution
1. in the /catalog/view/theme/default/stylesheet/stylesheet.css add:
2. In the /catalog/view/theme/default/template/common/header.tpl
after
add
change
to
and change
to
1. in the /catalog/view/theme/default/stylesheet/stylesheet.css add:
Code: Select all
#menu .nav > li.active {
background:#349ECA;
}
after
Code: Select all
<?php foreach ($categories as $category) { ?>
Code: Select all
<?php
$is_active = false;
if(isset($_GET['path'])){
list($category_id) = explode('_',$_GET['path']);
if(preg_match('~&path='.$category_id.'(&|_|$)~',$category['href'])){
$is_active = true;
}
}
?>
Code: Select all
<li class="dropdown"><a href="<?php echo $category['href']; ?>" class="dropdown-toggle" data-toggle="dropdown"><?php echo $category['name']; ?></a>
Code: Select all
<li class="dropdown<?php if($is_active):?> active<?php endif;?>"><a href="<?php echo $category['href']; ?>" class="dropdown-toggle" data-toggle="dropdown"><?php echo $category['name']; ?></a>
Code: Select all
<li><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a></li>
Code: Select all
<li<?php if($is_active):?> class="active"<?php endif;?>><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a></li>
The javascript solution might be better:
1. Add the following code to the /catalog/view/javascript/common.js
2. Add the same styles as before to the /catalog/view/theme/default/stylesheet/stylesheet.css
1. Add the following code to the /catalog/view/javascript/common.js
Code: Select all
<script>
$(document).ready(function() {
if(document.URL.match(/&path=(\d+)(_|&|$)/)){
$('a[href$="path='+RegExp.$1+'"]').each(function(){
$(this).parent().addClass('active');
})
}else if(document.URL.match(/[^/]+\/([^/]+)(\/|$)/)){
$('a[href$="/'+RegExp.$1+'"]').each(function(){
$(this).parent().addClass('active');
})
}
});
</script>
Code: Select all
#menu li.active {
background:#349ECA ;
}
Last edited by deepvision on Mon Jun 29, 2015 12:19 am, edited 2 times in total.
@deepvision: Thank for your reply.
BTW the example is of OC-1564, and not of OC-20xx, I hope you got that. Now if I use your 2nd solution(java script) then I believe that 1st solution is not required. Well I have as you have posted but there is no effect, the blue box does not stay fixed when I choose category and move the mouse away.
PS: Please can you also give me a solution for the same for OC-2031.
BTW the example is of OC-1564, and not of OC-20xx, I hope you got that. Now if I use your 2nd solution(java script) then I believe that 1st solution is not required. Well I have as you have posted but there is no effect, the blue box does not stay fixed when I choose category and move the mouse away.
PS: Please can you also give me a solution for the same for OC-2031.
Regards,
Sun Systems
Industrial Electronics and Instrumentation
Yes, the 1st solution is not required.
The 2nd one works fine with the OC-2031. Just make sure the menu background color is different from the active menu background in the new css.
P.S. Updated the javascript to work with SEO enabled URLs as well.
The 2nd one works fine with the OC-2031. Just make sure the menu background color is different from the active menu background in the new css.
P.S. Updated the javascript to work with SEO enabled URLs as well.
Last edited by deepvision on Mon Jun 29, 2015 12:19 am, edited 1 time in total.
The same javascript works for me in the latest 1.5.6.4
And here is the css code for the default 1.5.6.4 theme:
And here is the css code for the default 1.5.6.4 theme:
Code: Select all
#menu li.active >a{
background:black;
border-radius:5px;
}
Thanks a ton deepvision, it is working 100% perfect in both versions of OC, no issues till now.deepvision wrote:The same javascript works for me in the latest 1.5.6.4
And here is the css code for the default 1.5.6.4 theme:
Code: Select all
#menu li.active >a{ background:black; border-radius:5px; }
Regards,
Sun Systems
Industrial Electronics and Instrumentation
@Deepvision: This worked fine for 3 months and I feel that I must have added some ext that has stopped this highlight and stay function from working and I don't know what I have done to cause this, I have PM'd my site url to you, please can you kindly just have a look as to what could have stop working.
Thank you for your time.
Thank you for your time.
Regards,
Sun Systems
Industrial Electronics and Instrumentation
You must have received a mail from opencart forums that you have a new PM also you can login to your pm box and you will see it. I have just checked and seen that you have not yet retrieved my PM.deepvision wrote:I don't see any PM
Regards,
Sun Systems
Industrial Electronics and Instrumentation
No, there is no unread emails in my PM. Every time I get a notification, then login and read one.sunsys wrote:You must have received a mail from opencart forums that you have a new PM also you can login to your pm box and you will see it. I have just checked and seen that you have not yet retrieved my PM.deepvision wrote:I don't see any PM
None from you. Are you sure it is for me? Or maybe there is a forum bug.
Who is online
Users browsing this forum: No registered users and 117 guests