Dynamically changing links in a web page menu when a link is clicked [message #182189] |
Wed, 17 July 2013 18:37 |
Jason Bodine
Messages: 1 Registered: July 2013
Karma: 0
|
Junior Member |
|
|
Hi all,
Please excuse me if this question has been asked before, but I am new to php and can't seem to find the answer to my question anywhere.
I am designing a website for my company. The site will have a JQuery accordion menubar across the top and a sidebar menu as well. What I would like to do, using php in order to save myself the trouble of cluttering my html with menu code on every single page on the site, is make it so that when someone clicks on a link in the menubar, the links listed in the sidebar change according to what was clicked. For example, if someone were to click on "About" in the menubar, the sidebar would display different "About"-related hyperlinks ("About Us", "Management", "Our Staff", "Job Opportunities," etc.) and then, if the user then selects "Products and Services" from the top menu, the side menu would change with a list of new links related to that one.
Is this possible, and if so, how do I do this? Any help is appreciated!
Thanks!
Jason
|
|
|
Re: Dynamically changing links in a web page menu when a link is clicked [message #182190 is a reply to message #182189] |
Wed, 17 July 2013 18:49 |
|
richard
Messages: 213 Registered: June 2013
Karma: 0
|
Senior Member |
|
|
On Wed, 17 Jul 2013 11:37:20 -0700 (PDT), Jason Bodine wrote:
> Hi all,
> Please excuse me if this question has been asked before, but I am new to php and can't seem to find the answer to my question anywhere.
>
> I am designing a website for my company. The site will have a JQuery accordion menubar across the top and a sidebar menu as well. What I would like to do, using php in order to save myself the trouble of cluttering my html with menu code on every single page on the site, is make it so that when someone clicks on a link in the menubar, the links listed in the sidebar change according to what was clicked. For example, if someone were to click on "About" in the menubar, the sidebar would display different "About"-related hyperlinks ("About Us", "Management", "Our Staff", "Job Opportunities," etc.) and then, if the user then selects "Products and Services" from the top menu, the side menu would change with a list of new links related to that one.
>
> Is this possible, and if so, how do I do this? Any help is appreciated!
>
> Thanks!
> Jason
One possible way that comes to mind is the use of an ifrane.
Setup an iframe where the menu is to be.
Using php, have php set the values for the link they clicked.
I do something similar on my site.
When a user clicks on the year, the iframe content changes accordingly.
Not the entire page.
www.mroldies.net
|
|
|
|
Re: Dynamically changing links in a web page menu when a link is clicked [message #182193 is a reply to message #182189] |
Wed, 17 July 2013 19:33 |
The Natural Philosoph
Messages: 993 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 17/07/13 19:37, Jason Bodine wrote:
> Hi all,
> Please excuse me if this question has been asked before, but I am new to php and can't seem to find the answer to my question anywhere.
>
> I am designing a website for my company. The site will have a JQuery accordion menubar across the top and a sidebar menu as well. What I would like to do, using php in order to save myself the trouble of cluttering my html with menu code on every single page on the site, is make it so that when someone clicks on a link in the menubar, the links listed in the sidebar change according to what was clicked. For example, if someone were to click on "About" in the menubar, the sidebar would display different "About"-related hyperlinks ("About Us", "Management", "Our Staff", "Job Opportunities," etc.) and then, if the user then selects "Products and Services" from the top menu, the side menu would change with a list of new links related to that one.
>
> Is this possible,
yes
> and if so, how do I do this?
javascript. Not PHP
> Any help is appreciated!
>
> Thanks!
> Jason
--
Ineptocracy
(in-ep-toc’-ra-cy) – a system of government where the least capable to lead are elected by the least capable of producing, and where the members of society least likely to sustain themselves or succeed, are rewarded with goods and services paid for by the confiscated wealth of a diminishing number of producers.
|
|
|
Re: Dynamically changing links in a web page menu when a link is clicked [message #182194 is a reply to message #182189] |
Wed, 17 July 2013 20:34 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 7/17/2013 2:37 PM, Jason Bodine wrote:
> Hi all,
> Please excuse me if this question has been asked before, but I am new to php and can't seem to find the answer to my question anywhere.
>
> I am designing a website for my company. The site will have a JQuery accordion menubar across the top and a sidebar menu as well. What I would like to do, using php in order to save myself the trouble of cluttering my html with menu code on every single page on the site, is make it so that when someone clicks on a link in the menubar, the links listed in the sidebar change according to what was clicked. For example, if someone were to click on "About" in the menubar, the sidebar would display different "About"-related hyperlinks ("About Us", "Management", "Our Staff", "Job Opportunities," etc.) and then, if the user then selects "Products and Services" from the top menu, the side menu would change with a list of new links related to that one.
>
> Is this possible, and if so, how do I do this? Any help is appreciated!
>
> Thanks!
> Jason
>
Jason,
PHP is server side - to execute any PHP code, the client must make a
call to the server. While this can be done using Ajax, it requires
Javascript code on the client as well as PHP code on the server. As
such, I think it's a bit of overkill for what is basically static
information (the same info for the same menu item on each page).
You don't have to have the Javascript code in every page; it can be
included - and you don't even need PHP to do it. Try
comp.lang.javascript for more information.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|
Re: Dynamically changing links in a web page menu when a link is clicked [message #182195 is a reply to message #182189] |
Wed, 17 July 2013 23:28 |
Denis McMahon
Messages: 634 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On Wed, 17 Jul 2013 11:37:20 -0700, Jason Bodine wrote:
> I am designing a website for my company. The site will have a JQuery
> accordion menubar across the top and a sidebar menu as well. What I
> would like to do, using php in order to save myself the trouble of
> cluttering my html with menu code on every single page on the site, is
> make it so that when someone clicks on a link in the menubar, the links
> listed in the sidebar change according to what was clicked.
To do this at the php level implies some sort of reloading of the page,
or at least the sidebar (is it in a separate frame?) when the menu link
is clicked, with the relevant submenu data loaded.
If you want this to happen inside the page without a reload, that's
something you'd want to do client side, and that's not really a php
issue, although you might use an ajax request in the javascript code on
the client to ask the server for the relevant menu links to display.
You mention jquery - the normal suggestion in this case is to go and find
a jquery forum and ask the question there. There are probably other
javascript methods to do this, but they would be equally off topic here,
but perhaps on topic in comp.lang.javascript - however that latter group
is generally dismissive of jquery (and indeed most libraries) and will
probably suggest that you find a more relevant forum.
So, I think that first of all you need to decide whether:
(a) the menu change is going to happen with a page reload
(b) the menu is going to be in a frame and the menu frame will reload
(c) the menu change is going to happen client side using submenu data
provided as part of the initial pageload
(d) the menu change is going to happen client side using submenu data
provided in response to a menu click
Then you will know what data you need to provide, when to provide it,
what stimuli will trigger its provision, and whether you';re going to be
working client side or server side or both.
Once you know what bits you need to do server side in php, come back and
ask here if you need any help with them.
--
Denis McMahon, denismfmcmahon(at)gmail(dot)com
|
|
|
Re: Dynamically changing links in a web page menu when a link is clicked [message #182197 is a reply to message #182189] |
Thu, 18 July 2013 14:21 |
bill
Messages: 310 Registered: October 2010
Karma: 0
|
Senior Member |
|
|
On 7/17/2013 2:37 PM, Jason Bodine wrote:
> Hi all,
> Please excuse me if this question has been asked before, but I am new to php and can't seem
to find the answer to my question anywhere. I am designing a
website for my company.
The site will have a JQuery accordion menubar across the top and
a sidebar menu as well.
What I would like to do, using php in order to save myself the
trouble of cluttering my
html with menu code on every single page on the site, is make it
so that when someone
clicks on a link in the menubar, the links listed in the sidebar
change according to what
was clicked. For example, if someone were to click on "About" in
the menubar, the
sidebar would display different "About"-related hyperlinks
("About Us", "Management",
"Our Staff", "Job Opportunities," etc.) and then, if the user
then selects "Products and
Services" from the top menu, the side menu would change with a
list of new links related
to that one.
>
> Is this possible, and if so, how do I do this? Any help is appreciated!
>
> Thanks!
> Jason
>
This is actually fairly easy to do, once you know how to use
AJAX. The click sends a request to a PHP script that generates
the sidebar code and the ajax code on the client side puts it
there. I don't use jquery, but I am sure that jquery includes
routines to do exactly that.
bill
|
|
|
Re: Dynamically changing links in a web page menu when a link is clicked [message #182198 is a reply to message #182189] |
Thu, 18 July 2013 16:36 |
Martin Leese
Messages: 23 Registered: June 2012
Karma: 0
|
Junior Member |
|
|
Jason Bodine wrote:
> Hi all,
> Please excuse me if this question has been asked before, but I am new to php and can't seem to find the answer to my question anywhere.
>
> I am designing a website for my company. The site will have a JQuery accordion menubar across the top and a sidebar menu as well. What I would like to do, using php in order to save myself the trouble of cluttering my html with menu code on every single page on the site, is make it so that when someone clicks on a link in the menubar, the links listed in the sidebar change according to what was clicked. For example, if someone were to click on "About" in the menubar, the sidebar would display different "About"-related hyperlinks ("About Us", "Management", "Our Staff", "Job Opportunities," etc.) and then, if the user then selects "Products and Services" from the top menu, the side menu would change with a list of new links related to that one.
>
> Is this possible, and if so, how do I do this? Any help is appreciated!
Other people have suggested using AJAX.
Alternatively, you could include all the
options as HTML in your sidebar, but then
make all but one of them invisible using
the CSS {display: none;}. Then, when the
user clicks on a link in the menubar, use
JavaScript to change what HTML is made
visible in the sidebar.
Whichever way you do this, PHP will not do
it. PHP just generates HTML (perhaps in
response to a JavaScript AJAX request).
This is therefore the wrong newsgroup.
--
Regards,
Martin Leese
E-mail: please(at)see(dot)Web(dot)for(dot)e-mail(dot)INVALID
Web: http://members.tripod.com/martin_leese/
|
|
|
Re: Dynamically changing links in a web page menu when a link is clicked [message #182199 is a reply to message #182198] |
Thu, 18 July 2013 18:00 |
The Natural Philosoph
Messages: 993 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 18/07/13 17:36, Martin Leese wrote:
> Jason Bodine wrote:
>> Hi all,
>> Please excuse me if this question has been asked before, but I am new
>> to php and can't seem to find the answer to my question anywhere.
>>
>> I am designing a website for my company. The site will have a JQuery
>> accordion menubar across the top and a sidebar menu as well. What I
>> would like to do, using php in order to save myself the trouble of
>> cluttering my html with menu code on every single page on the site,
>> is make it so that when someone clicks on a link in the menubar, the
>> links listed in the sidebar change according to what was clicked. For
>> example, if someone were to click on "About" in the menubar, the
>> sidebar would display different "About"-related hyperlinks ("About
>> Us", "Management", "Our Staff", "Job Opportunities," etc.) and then,
>> if the user then selects "Products and Services" from the top menu,
>> the side menu would change with a list of new links related to that one.
>>
>> Is this possible, and if so, how do I do this? Any help is appreciated!
>
> Other people have suggested using AJAX.
> Alternatively, you could include all the
> options as HTML in your sidebar, but then
> make all but one of them invisible using
> the CSS {display: none;}. Then, when the
> user clicks on a link in the menubar, use
> JavaScript to change what HTML is made
> visible in the sidebar.
>
> Whichever way you do this, PHP will not do
> it. PHP just generates HTML (perhaps in
> response to a JavaScript AJAX request).
> This is therefore the wrong newsgroup.
>
the only way you can do it server side is to cause any click to reload
the page, or part of the page from the server.
But invisible divs are cheap enough, if you don't mind using javascript
to handle the context sensitivity, and its a hell of a lot faster.
--
Ineptocracy
(in-ep-toc’-ra-cy) – a system of government where the least capable to lead are elected by the least capable of producing, and where the members of society least likely to sustain themselves or succeed, are rewarded with goods and services paid for by the confiscated wealth of a diminishing number of producers.
|
|
|
Re: Dynamically changing links in a web page menu when a link is clicked [message #182295 is a reply to message #182189] |
Sat, 27 July 2013 15:36 |
bill
Messages: 310 Registered: October 2010
Karma: 0
|
Senior Member |
|
|
On 2013-07-17 2:37 PM, Jason Bodine wrote:
> Hi all,
....
Your lines are too long so I snipped them.
....
>
I do not have an answer to your question as asked, but maybe an alternative:
Why not just use Masterborders for where you need the menues
changed? The click could simply load a new page even though it's
identical or however you want to set it up, but has a different MB with
the NAV menues you want?
Also, I haven't tried it, but isn't there a way to hide and unhide
objects dynamically? That sounds like it might fit the bill.
I'm no guru and I'm sure others will come along with more specific
answers, but ... thought I'd pass along my thoughts.
Regards,
Twayne`
|
|
|