Jump to content

Putting Html Code On My Hosting Server


rmcellig
 Share

Recommended Posts

I just created a new menu (finally)!! What I like about it is that I keep the CSS files on my hosting server so that if I wan to change my menu stylings, I just alter this file and every occurrence of the menu changes automatically on my Yola website.What I would love to do is be able to do the same thing with the HTML code that I paste into the HTML widgets that I have for each page that my menu appears. Is there a way to have the HTML code sit on my hosting server so that If I want to make changes to the menu content, I could just open up the HTML file on the hosting server, make the change and then all of my menus on my Yola site will update automatically (I sure hope so!!)

Link to comment
Share on other sites

Not with straight HTML, but using a server side language you can include other documents (be they HTML or other server/client side code). In PHP, all you need to do is:<?php include_once("menu.html"); ?>Put that wherever you want your menu to appear on a page. Now, changes in menu.html will be reflected throughout any sites using that line. You need to make sure your webhost has PHP enabled. All that is in menu.html is exactly the HTML you would usually copy into a given page to display the menu.

Link to comment
Share on other sites

Thanks! I think this is what I want. So my understanding is that instead of pasting HYML code on all of my 35 pages, I can just put the php code on the page, and then update the html file from the server side and then every wher the PHP code appears, the menus will change automatically? That makes more sense than having to change 35 pages of HTML code!Can you try this out and let me know if it works for you?<?php include_once("http://sd.mcran.com/assets/menu/newmenu.html"); ?>This is the link to the html file on my hosting server. If you enter the url in a web browser you should see the menu that is generated from the html code, although the sub menus don't seem to work. Not sure why. Am I doing something wrong?

Link to comment
Share on other sites

The way you've arranged your menus is a little odd. The div .select_sub is redundant - you can style an ul as freely as a div. So, that can go altogether. The normal arrangement is:<ul id="menu">

<li>Menu item
<ul>
<li>Sub menu item</li><li>Sub menu item</li>

</ul>
</li>

<li>Menu item
<ul>
<li>Sub menu item</li><li>Sub menu item</li>

</ul>
</li>
</ul>You don't need any more classes or ids than that.#menu li ul {display: none;}to hide the sub level menu.#menu li:focus #menu li ul, #menu li:hover #menu li ul {display: block;}reveals it when the top level li is hovered over.It's too much for my brain (it's nearly 3am here!) to try to straighten out your code, but it could be a lot simpler and lose many of the classes. Also, you are using <b /> tags, which are depracated in modern doctypes and then styling them in CSS. That's kind of odd. Again, just style the list links:#menu li a{font-weight: bold;}Using child selectors with enough specificity saves you needing to clutter the HTML with classes and ids and leaves you with more generic and flexible stylesheets.That aside, the include statement you had looks fine - it doesnt work for me because cross server including isn't as easy as that (I don't know how to make it work if at all). It will save a lot of work if you want to add a new menu item! Think what else you could include, too. If you have the same header, footer, etc. you can create a template page that only has a dozen lines in it, leaving the page a lot clearer when entering the unique page content. It also means servers can cache the includes, making loading times faster.I also noticed last night that each top level menu item seems to be an ul unto itself. That isn't necessary either. The top level list items should all be part of the same ul, with their own ul where you have sub level items. You need to float the list items or give the ul (or li, one of the two) display: inline or inline-block to make them sit on the same line. But again it's less HTML, which is good. Edited by chibineku
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...