Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

HTML Forum


You are currently viewing our HTML Forum as a guest. Please register to participate.
Login



Post a Project »

Find a Professional HTML Freelancer!

Find a Freelancer to help you with your HTML projects

FREE Outsourcing eBook!

Reply
Secondary menu changes according to different sections of the website.
Old 08-17-2008, 06:12 AM Secondary menu changes according to different sections of the website.
Novice Talker

Posts: 10
Trades: 0
Hi all.

Don't know where to put this thread.

Take a look at this site: http://www.epamedia.eu/en/index.php

I would like to create a secondary menu on the side of my website like the website above. That second menu on the side changes according to which page the user is on. So if the user clicks on 'Countries' in the top main menu, the list in the second menu changes with several links. Then if the user clicks on 'Press', the second menu changes once again to suit the needs of the Press webpage.

How would I go about doing this? Is it simple HTML and PHP trickery?

Thanks in advance.
ill_phil is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-17-2008, 07:00 AM Re: Secondary menu changes according to different sections of the website.
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,380
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
or HTML and ASP, ColdFusion, .NET, Perl etc trickery

set a flag in a page or check the URL structure and load a different menu include
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 08-17-2008, 08:34 AM Re: Secondary menu changes according to different sections of the website.
Novice Talker

Posts: 10
Trades: 0
Are there any tutorials on this? Preferably with PHP.
ill_phil is offline
Reply With Quote
View Public Profile
 
Old 08-17-2008, 10:26 AM Re: Secondary menu changes according to different sections of the website.
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
If you are asking if there is one way to do it, there isn't. It is simple programming though. The way I do it is to have a variable identifying each page, then create an IF statement that displays different submenus in the included file, where applicable. Any PHP tutorial will give you the basic tools you need to accomplish this.
__________________
I build web things. I work for the startup
Please login or register to view this content. Registration is FREE
.
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 08-25-2008, 03:11 PM Re: Secondary menu changes according to different sections of the website.
Novice Talker

Posts: 10
Trades: 0
Could you show some code, to get me on the right track, or show me how things are done? Would be much appreciated. Unless anyone else knows of any other simpler ways?
ill_phil is offline
Reply With Quote
View Public Profile
 
Old 08-26-2008, 12:04 PM Re: Secondary menu changes according to different sections of the website.
angele803's Avatar
Perfectly Imperfect

Posts: 1,772
Name: Stephanie
Location: Oklahoma
Trades: 2
I would do the same thing wayfarer would.

I use coldfusion, so I am not sure how well this will translate to php, but hopefully it will give you a better idea.

Add a variable to your links. So if you had something like:
"http://www.mysite.com/index.php"
you would add a variable to the end like this:
"http://www.mysite.com/index.php?menu=1"

Then, in your code, use "if" statements to determine the value of "menu".
For example, if the value of "menu" is one, you would display the code for the first menu. If "menu" is equal to 2, you would show the code for the second menu. And so on.

It would probably be a good idea to put the different menus into includes. That way it will keep your main page smaller.

Does that clear it up any?
__________________

Please login or register to view this content. Registration is FREE
angele803 is offline
Reply With Quote
View Public Profile
 
Old 08-26-2008, 04:09 PM Re: Secondary menu changes according to different sections of the website.
Novice Talker

Posts: 10
Trades: 0
Hmm that makes some sense.

i'd also do the same for the content, so that the website knows which .php file to include depending on the variable, right?

how would i change the variable from just the index.php page for example? how do i set the variable within my menu.php file?

this is what i mean:

-user clicks on "Services".
-the $page variable is set to 4.
-because the variable is set to 4, the corresponding submenu is loaded.
-because the variable is set to 4, the corresponding content is loaded.


is all of this possible within the index.php file?
ill_phil is offline
Reply With Quote
View Public Profile
 
Old 08-26-2008, 04:47 PM Re: Secondary menu changes according to different sections of the website.
angele803's Avatar
Perfectly Imperfect

Posts: 1,772
Name: Stephanie
Location: Oklahoma
Trades: 2
Yes, this is all possible with just on file (in your case, the index.php file) plus some include files.

You could have several different include files. For example, menu1.php, menu2.php, menu3.php.....content1.php, content2.php, content3.php.
Then, you just display those files inside your index.php depending on what the variable is set to.
In coldfusion, it would look something like this:
Code:
.
.
.
<body>
     <!--Set defaults for your variables so you don't get any errors -->
     <cfparam name="menu" default="1">
     <cfparam name="page" default="1">

      
      <div id="header">
         Header Stuff Here - Maybe your main navigation
      </div>
      
      <div id="side_menu">    
     <!--This part would go into the side menu area of your page  -->
         <cfif #menu# eq 1>
             <cfinclude template="menu1.cfm">
         <cfelseif #menu# eq 2>
             <cfinclude template="menu2.cfm">
         <cfelseif #menu# eq 3>
             <cfinclude template="menu3.cfm">
         </cfif>
     </div>

     <div id="content">
         <!--This part would go into the content area of your page  -->
         <cfif #page# eq 1>
             <cfinclude template="page1.cfm">
         <cfelseif #page# eq 2>
             <cfinclude template="page2.cfm">
         <cfelseif #page# eq 3>
             <cfinclude template="page3.cfm">
         </cfif>
     </div>
</body>
.
.
.
**Edit***
I don't know much about PHP (sadly), but I think your "if" statements would look something like this:
Code:
if ($menu == 1)
  include 'menu1.php';
elseif ($menu == 2)
  include 'menu2.php';
elseif ($menu == 3)
  include 'menu3.php';
__________________

Please login or register to view this content. Registration is FREE

Last edited by angele803; 08-26-2008 at 04:54 PM..
angele803 is offline
Reply With Quote
View Public Profile
 
Old 08-27-2008, 02:59 AM Re: Secondary menu changes according to different sections of the website.
Novice Talker

Posts: 10
Trades: 0
Alright, but if it's all within one page, how do I change the $menu variable when I click on a link in the top menu?
ill_phil is offline
Reply With Quote
View Public Profile
 
Old 08-28-2008, 04:13 AM Re: Secondary menu changes according to different sections of the website.
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,380
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
you pass it as a querystring.

href="/?page=2"
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 08-28-2008, 10:14 AM Re: Secondary menu changes according to different sections of the website.
Novice Talker

Posts: 10
Trades: 0
I've got the hang of it now.

Thanks all for taking your time to answer my questions.
ill_phil is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Secondary menu changes according to different sections of the website.
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.46246 seconds with 12 queries