Support Forums

'Active' state on menu

This is a discussion on 'Active' state on menu within the Templates, HTML, CSS, and Design Help forums, part of the General category; Can anyone explain the php needed to make the top buttons stay on there 'active' state once clicked? I've found ...


Go Back   68 Classifieds Forums > General > Templates, HTML, CSS, and Design Help

Reply
 
Thread Tools Display Modes
Old 08-09-2007, 04:44 AM   #1
Senior Member
 
Join Date: Sep 2006
Posts: 236
Rep Power: 20
Tim_A is on a distinguished road
Default 'Active' state on menu

Can anyone explain the php needed to make the top buttons stay on there 'active' state once clicked?

I've found a few scripts but they won't seem to work because of all the variables after the category.php

e.g. i've now got a custom button at the top linked to category.php?cat=charities so i'd like the button to stay in the active/hover state when it's clicked.

as always any help appreciated.
__________________
V4.0.9 Developer

Last edited by Tim_A; 08-09-2007 at 05:06 AM.
Tim_A is offline   Reply With Quote
Old 08-09-2007, 08:54 AM   #2
68 Classifieds Staff
 
Eric Barnes's Avatar
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,453
Rep Power: 130
Eric Barnes is just really nice Eric Barnes is just really nice
Default

You could do some thing like this:
Code:
<a href="#" {if $smarty.get.cat == 'charities'}class="active"{/if}></a>
__________________
Eric Barnes
68 Classifieds Developer
Customer Area | Issue Tracker | Documentation | 68C Mods | 68 @ Twitter | My Modules
Eric Barnes is offline   Reply With Quote
Old 08-09-2007, 10:02 AM   #3
Senior Member
 
Join Date: Sep 2006
Posts: 236
Rep Power: 20
Tim_A is on a distinguished road
Default

Thanks Eric...

that works,

but.... (there's always a but with me!!)

it won't work if you go into child categories.

Is there a solution?

Cheers
__________________
V4.0.9 Developer
Tim_A is offline   Reply With Quote
Old 08-09-2007, 10:17 AM   #4
68 Classifieds Staff
 
Eric Barnes's Avatar
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,453
Rep Power: 130
Eric Barnes is just really nice Eric Barnes is just really nice
Default

How many sub categories do you have? You could always list out each one in the if statement:
Code:
{if $smarty.get.cat == 'charities' || $smarty.get.cat =='charitiessubcat'}
__________________
Eric Barnes
68 Classifieds Developer
Customer Area | Issue Tracker | Documentation | 68C Mods | 68 @ Twitter | My Modules
Eric Barnes is offline   Reply With Quote
Old 08-09-2007, 10:20 AM   #5
Senior Member
 
Join Date: Sep 2006
Posts: 236
Rep Power: 20
Tim_A is on a distinguished road
Default

over 25 in some places

i've worked out how to do it for my pages which end in .php
__________________
V4.0.9 Developer
Tim_A is offline   Reply With Quote
Old 08-09-2007, 10:35 AM   #6
68 Classifieds Staff
 
Eric Barnes's Avatar
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,453
Rep Power: 130
Eric Barnes is just really nice Eric Barnes is just really nice
Default

Will you post how you are doing it with the php pages and maybe that give me a better idea.
__________________
Eric Barnes
68 Classifieds Developer
Customer Area | Issue Tracker | Documentation | 68C Mods | 68 @ Twitter | My Modules
Eric Barnes is offline   Reply With Quote
Old 08-09-2007, 10:39 AM   #7
Senior Member
 
Join Date: Sep 2006
Posts: 236
Rep Power: 20
Tim_A is on a distinguished road
Default

At the top of the .php page i've got this:

PHP Code:
<?php $thispage "cardiff";?>
Then the navigation has this:

PHP Code:
<li class="cardiff"><a class="<?php if($thispage=="cardiff"){echo"active";} ?>" href="cardiff.php">Cardiff</a></li>
__________________
V4.0.9 Developer
Tim_A is offline   Reply With Quote
Old 08-09-2007, 11:25 AM   #8
68 Evangelist & Developer
 
 
Join Date: Jan 2007
Location: Pennsylvania, USA
Posts: 1,922
Rep Power: 57
Mike-N-Tosh is just really nice Mike-N-Tosh is just really nice
Default

Can you just make an "a:link, hover, active" the same in your stylesheet?

Just a thought,
-Mike
__________________
Mike-N-Tosh
IndianaPC.org - A community website (v3.1.10 Developer - heavily modified & used as the CMS)
Sandbox [localhost(v3.1.10, v4.0.9, 4.1.10)] for development and customization
Visit My blog: reviews, tips, tricks, tutorials and my store with Templates, Mods & Docs
Web Hosting | Web Design & Development | 68 Classifieds Customizations
I am not a 68C employee, just a user and try to help out
Mike-N-Tosh is offline   Reply With Quote
Old 08-09-2007, 12:08 PM   #9
Staff
 
Join Date: Mar 2006
Posts: 454
Rep Power: 27
Blair will become famous soon enough
Default

Quote:
Originally Posted by Tim_A
At the top of the .php page i've got this:

PHP Code:
<?php $thispage "cardiff";?>
Then the navigation has this:

PHP Code:
<li class="cardiff"><a class="<?php if($thispage=="cardiff"){echo"active";} ?>" href="cardiff.php">Cardiff</a></li>
If you assign a php variable and then check to see if it exists later in the page, it will always be true. I don't think you need the
PHP Code:
<?php $thispage "cardiff";?>
If you want a tab to appear in some other 'state' than the other tabs (and each tab represents a parent category), you're going to have to figure out some way of finding out the top category from the category name (appended as a query string) in the address.
__________________
Blair
68C Staff

68C Downloads | Report a Bug | Knowledge Base
Blair is offline   Reply With Quote
Old 08-09-2007, 01:17 PM   #10
68 Classifieds Staff
 
Eric Barnes's Avatar
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,453
Rep Power: 130
Eric Barnes is just really nice Eric Barnes is just really nice
Default

Mike.

Try this.

Open the category.php file and below the require_once statements add this function:

PHP Code:
function getAbsoluteParent($id)
    {
        global 
$db;
        
$arr = array();
        
$sSQL="SELECT id,parent_id FROM ".PREFIX."categories WHERE id=".$id." AND display<>'N' AND cLink='' ORDER BY cORDER DESC, name ASC";
        
$result=$db->query($sSQL);
        
$row $result->fetch();
        
        if (
$row['parent_id']!=0
        {
            
$path getAbsoluteParent($row['parent_id']);
        } 
        else
        {
            
$path $row['id'];
        }
        return 
$path;
    } 
Then inside the if statement:
PHP Code:
if($cat)
            {
                
$keywords$cat['cKeywords'];
                
$description=$cat['description'];
                
$promo $cat['cPromo'];
//add this line:
                
$class_tpl->assign('parent'getAbsoluteParent($cat['id'])); 
Then in your template file:
{if $parent == 1} change 1 to the actual parent id.
__________________
Eric Barnes
68 Classifieds Developer
Customer Area | Issue Tracker | Documentation | 68C Mods | 68 @ Twitter | My Modules
Eric Barnes is offline   Reply With Quote
Reply

Thread Tools
Display Modes



All times are GMT -4. The time now is 01:39 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0