Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Re: [Westin] Has anybody done a javascript drop down selection list for categories?

Quote Reply
Re: [Westin] Has anybody done a javascript drop down selection list for categories? In reply to
Hi,

I hope you appreciate this - its taken me bloody ages to do ;)

First - you need 2 new globals:

load_sub_cats_menu
Code:
sub {

my $tbl = $DB->table('Category');
my $sth = $tbl->select( { FatherID => $_[0] } );

my @loop;
my $i = 0;
while (my $hit = $sth->fetchrow_hashref) {
$hit->{URL} = $CFG->{build_root_url} . "/" . $tbl->as_url( $hit->{Full_Name} ) . "/" . $CFG->{build_index};
push @loop, $hit;
}

return { load_sub_cats_menu_loop => \@loop }

}

make_top_nav_loop
Code:
sub {

my $tbl = $DB->table('Category');
my $sth = $tbl->select( { CatDepth => 0 } );

my @loop;
while (my $hit = $sth->fetchrow_hashref) {
$hit->{subcatcount} = $tbl->count( { FatherID => $hit->{ID} } ) || 0 ;
$hit->{URL} = $CFG->{build_root_url} . "/" . $tbl->as_url( $hit->{Full_Name} ) . "/" . $CFG->{build_index};
push @loop, $hit;
}

return { top_nav_menu => \@loop }
}

Then, upload the attached file (obviously decompress it =)) to the /static folder.

Then, in include_common_head.html, you need to add this at the end of it:

Code:
<link rel="stylesheet" type="text/css" href="<%config.build_static_url%>/chrometheme/chromestyle2.css" />
<script type="text/javascript" src="<%config.build_static_url%>/chromejs/chrome.js" ></script>

Then, finally in include_header.html, add the following (again, at the very bottom of the template):
Code:
<%make_top_nav_loop%>


<div class="chromestyle" id="chromemenu">
<ul>
<%loop top_nav_menu%>
<li><a href="<%URL%>" <%if subcatcount > 0%>rel="dropmenu<%row_num%>"<%endif%>><%Name%></a></li>
<%endloop%>
</ul>
</div>


<%loop top_nav_menu%>
<%load_sub_cats_menu($ID)%>
<%if load_sub_cats_menu_loop.length%>
<div id="dropmenu<%row_num%>" class="dropmenudiv">
<%loop load_sub_cats_menu_loop%>
<a href="<%URL%>"><%Name%></a>
<%endloop%>
</div>
<%endif%>
<%endloop%>


<script type="text/javascript">

cssdropdown.startchrome("chromemenu")

</script>

I've tested that now, and it all seems to be working fine =)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!

Last edited by:

Andy: May 12, 2009, 3:35 AM
Subject Author Views Date
Thread; hot thread Has anybody done a javascript drop down selection list for categories? Westin 8749 May 11, 2009, 4:58 PM
Thread; hot thread Re: [Westin] Has anybody done a javascript drop down selection list for categories?
Andy 8584 May 12, 2009, 1:52 AM
Thread; hot thread Re: [Andy] Has anybody done a javascript drop down selection list for categories?
Westin 8585 May 12, 2009, 2:42 AM
Thread; hot thread Re: [Westin] Has anybody done a javascript drop down selection list for categories?
Andy 8613 May 12, 2009, 3:36 AM
Thread; hot thread Re: [Andy] Has anybody done a javascript drop down selection list for categories?
Westin 8611 May 12, 2009, 3:40 AM
Thread; hot thread Re: [Westin] Has anybody done a javascript drop down selection list for categories?
Andy 8593 May 12, 2009, 3:47 AM
Thread; hot thread Re: [Andy] Has anybody done a javascript drop down selection list for categories?
Westin 8570 May 12, 2009, 3:50 AM
Post; hot thread Re: [Westin] Has anybody done a javascript drop down selection list for categories?
Andy 8560 May 12, 2009, 3:52 AM
Thread; hot thread Re: [Westin] Has anybody done a javascript drop down selection list for categories?
Westin 8601 May 12, 2009, 3:47 AM
Thread; hot thread Re: [Westin] Has anybody done a javascript drop down selection list for categories?
Andy 8576 May 12, 2009, 3:51 AM
Thread; hot thread Re: [Andy] Has anybody done a javascript drop down selection list for categories?
Westin 8581 May 12, 2009, 3:55 AM
Post; hot thread Re: [Westin] Has anybody done a javascript drop down selection list for categories?
Andy 8543 May 12, 2009, 4:04 AM
Post; hot thread Re: [Westin] Has anybody done a javascript drop down selection list for categories?
Westin 8586 May 12, 2009, 3:58 AM