# [SOLVED] Displaying menu in iframe to allow for global content block



## icp_nz (Apr 5, 2011)

Hi there

Have a website I've been asked to edit so that the menu is shown within an iframe (or similar) that pulls code from another html file to allow for a global content block type setup, i.e. I want to make changes to 'global-menu.html' and the changes to be shown on all pages that have the menu instead of having to alter the code on every single page

I have done this for the footer already and it's working great in all browsers, phones and tablets but the menu is a lot harder as it's a fade in/out drop-down menu which is directly above (and overlaps on hover) an interactive content scroller

I got it to work, sort of, but as the iframe goes over the content fader below the content fader is no longer interactive as the mouseover is on the iframe not the content fader

Any ideas?

www.
hydro
tech
.co
.nz


----------



## Fjandr (Sep 26, 2012)

*Re: Displaying menu in iframe to allow for global content block*

Is there a reason you want to use an iframe rather than doing it in PHP (or some other scripting language)?


----------



## icp_nz (Apr 5, 2011)

*Re: Displaying menu in iframe to allow for global content block*



Fjandr said:


> Is there a reason you want to use an iframe rather than doing it in PHP (or some other scripting language)?


Mostly due to time-frame, iframes are quick and easy and work well in all instances. Not really wanting to use PHP unless absolutely necessary

Do you have any ideas?

Thank you


----------



## Fjandr (Sep 26, 2012)

*Re: Displaying menu in iframe to allow for global content block*

I looked at your site, and I'm not seeing what the problem is. Which page(s) are affected, and what is the problem you're seeing (and what would you like to be happening that's not?).


----------



## icp_nz (Apr 5, 2011)

*Re: Displaying menu in iframe to allow for global content block*

Hi,

There is nothing displaying wrongly at the moment, but I would like the menu code to be in it's own html file (e.g. named global-menu.html) and then the code within this file to be displayed on each page to show the menu to simply allow a single edit to the global-menu.html file to change the menu on ALL pages

Currently I have to go through each page and alter the code even to make simple changes to global content like the menu, this of course isn't efficient at all so I would like that global content to be located in a single file for more efficient updating of the global content

If you have a look at the footer code you will see that it is an iframe showing global-footer.html so that if I need to update the footer I simply make a change to global-footer.html and it updates the footer on every single page

Thanks


----------



## Fjandr (Sep 26, 2012)

*Re: Displaying menu in iframe to allow for global content block*

Can you post the snippet of code you tried to build the menu iframe with?


----------



## icp_nz (Apr 5, 2011)

*Re: Displaying menu in iframe to allow for global content block*

Sorry I've since deleted it

It was virtually identical to the footer one except the actual code in global-menu.html was of course different - I was experimenting with exactly how much of the entire menu code to include in the global-menu.html file as well as z-indexing and positioning but nothing seemed to get the same effect it has now - either the menu would show behind the content slider or the menu would show above on mouseover and the content fader mouseover effects/controls would stop working


----------



## Fjandr (Sep 26, 2012)

*Re: Displaying menu in iframe to allow for global content block*

Alright. I'll try to look at it tomorrow and see if I can come up with a workable solution.


----------



## icp_nz (Apr 5, 2011)

*Re: Displaying menu in iframe to allow for global content block*



Fjandr said:


> Alright. I'll try to look at it tomorrow and see if I can come up with a workable solution.


Awesome! Very much appreciated :thumb:


----------



## icp_nz (Apr 5, 2011)

*Re: Displaying menu in iframe to allow for global content block*



Fjandr said:


> Alright. I'll try to look at it tomorrow and see if I can come up with a workable solution.


Hey mate, sorry to bug, did you manage to find anything?


----------



## Fjandr (Sep 26, 2012)

*Re: Displaying menu in iframe to allow for global content block*

I apologize for the delay in replying. Chemo was a bit worse this round than normal, and I forgot to check in on the forum. I'll try to get back on this in the next day or two.


----------



## icp_nz (Apr 5, 2011)

*Re: Displaying menu in iframe to allow for global content block*



Fjandr said:


> I apologize for the delay in replying. Chemo was a bit worse this round than normal, and I forgot to check in on the forum. I'll try to get back on this in the next day or two.


Oh ****, hope all is well


----------



## Fjandr (Sep 26, 2012)

*Re: Displaying menu in iframe to allow for global content block*

Ah, it's something I've been dealing with for years, so not a huge deal. It's just worse than usual on occasion, and this last week was one of those.

Unfortunately, I can't get the menu to work on a test site. I'm not sure were the issue is, but without spending hours tracking down and fixing whatever is causing the issue I can't set up a test for the iframe. Honestly, I would really recommend using a PHP insert. It'll do exactly what you want, and you just have to change the menu file to propagate changes across your entire site.

All you'd have to do is cut the menu out and place it in a file like "menu.html" and add the line <?php include('menu.html'); ?> in its place in every file you want the menu included. Then you just need to change the extension of each of those files from .htm or .html to .php. No other modifications to the site should be necessary.


----------



## icp_nz (Apr 5, 2011)

*Re: Displaying menu in iframe to allow for global content block*



Fjandr said:


> Ah, it's something I've been dealing with for years, so not a huge deal. It's just worse than usual on occasion, and this last week was one of those.
> 
> Unfortunately, I can't get the menu to work on a test site. I'm not sure were the issue is, but without spending hours tracking down and fixing whatever is causing the issue I can't set up a test for the iframe. Honestly, I would really recommend using a PHP insert. It'll do exactly what you want, and you just have to change the menu file to propagate changes across your entire site.
> 
> All you'd have to do is cut the menu out and place it in a file like "menu.html" and add the line <?php include('menu.html'); ?> in its place in every file you want the menu included. Then you just need to change the extension of each of those files from .htm or .html to .php. No other modifications to the site should be necessary.


Ok not really the route I was wanting to go but if it's faster, easier and will work fine then sounds good to me.

Does the menu.html file require any php in it? Did you test it and it worked fine?

Thank you :smile:


----------



## Fjandr (Sep 26, 2012)

*Re: Displaying menu in iframe to allow for global content block*

You'll need the PHP block I posted in every file that needs the menu in it.

I can't test it on my end because of the number of variables that can change between server configurations with scripting languages. The best thing you can do is create a copy of one or more of your pages in a temporary directory and then test the changes. It's a bad idea to test anything on a working site.


----------



## icp_nz (Apr 5, 2011)

*Re: Displaying menu in iframe to allow for global content block*



Fjandr said:


> You'll need the PHP block I posted in every file that needs the menu in it.
> 
> I can't test it on my end because of the number of variables that can change between server configurations with scripting languages. The best thing you can do is create a copy of one or more of your pages in a temporary directory and then test the changes. It's a bad idea to test anything on a working site.


Yep yep aware of that lol ok I'll have a play when I get time hopefully today


----------



## Fjandr (Sep 26, 2012)

*Re: Displaying menu in iframe to allow for global content block*

Sorry, I misread your post. No, the menu.html file doesn't need anything other than the menu code currently in all of the site's files.


----------



## icp_nz (Apr 5, 2011)

*Re: Displaying menu in iframe to allow for global content block*



Fjandr said:


> Sorry, I misread your post. No, the menu.html file doesn't need anything other than the menu code currently in all of the site's files.


Hi sorry before I do this am I going to have the same problem as when using iFrames where due to the mouse-over expansion of the menu it will overlap the content fader on the homepage and thus stop the mouse-over effects on the content fader/rotator from working?


----------



## Fjandr (Sep 26, 2012)

*Re: Displaying menu in iframe to allow for global content block*

No, it should work the same as it does now. When loaded, the page source should be identical to what you see right now.


----------



## icp_nz (Apr 5, 2011)

*Re: Displaying menu in iframe to allow for global content block*



Fjandr said:


> No, it should work the same as it does now. When loaded, the page source should be identical to what you see right now.


Completed the testing and all went well, have now implemented the changes and successfully have a global menu and global footer file that each page pulls so updates are now much, much simpler!

Content fader still works well and have tested in FF, IE, Chrome, Safari and Opera all with success. Works on iPhones, Android phones and Windows phones.

Thanks very much my friend.


----------



## Fjandr (Sep 26, 2012)

Quite welcome. PHP (or any scripting language, for that matter) does make many things far more simple than trying to get them to work through CSS and Javascript.


----------

