HTML link HTML code inside (for toolbar across multiple pages) - html

I would like to be able to use something similar to a stylesheet but with HTML so that I only have to edit one set of code to edit the toolbar's HTML code across multiple pages. Is there a way to use a tag or something to import HTML code into the body section,

You can try to type out your navigation bar / header in a html page, save it has header.php and then in all of your other pages (for example index page), type in
<?php get_header(); ?>
at the beginning to grab the header. Make sure the header.php is in the same folder as your other files (for example index.php)..
Let me know if it does or doesn't work.

Your best bet is to make sure your server has PHP installed, then use include
<html>
<body>
<?php
include "toolbar.html";
?>
</body>
</html>

Related

How to add a HTML Home page to a prestashop page

I've developed a custom HTML homepage for my prestashop site, but it seems I do not know how to incorporate it, I've tried looking into the prestashop forums, but all it shows are for .tpl files, is there a way for me to link them to the homepage?
Can I just link it as an html page or do I really need to put it inside a tpl page for it to work?
Create your .html file (say 'test.html).
In test file you need to
add these lines of code before your html code
<?php
include(dirname(__FILE__).'/config/config.inc.php');
Tools::displayFileAsDeprecated();
include(dirname(__FILE__).'/header.php');?>
Also add these lines after your html code
<?php include(dirname(__FILE__).'/footer.php');?>
Place the test.html file in the public_html folder.
Now you need to add the page to link with your site.
If it is home page you need to add it to index.php otherwise you can just add the url (http://mysite/test.html) to menu bar or footer links, where ever you want to put it.
I have placed my php page link in the footer information part using anchor tag as shown in the image
In prestashop you can find "Home Editorial" module, in this module you can put your html obviously the module need to be transplant in displayHome position.

HTML - constant headers/auto updating headers?

Is it possible in HTML to create a constant header? e.g. a header that you only write in one file and goes out to all the sub webpages on the website instead of having to update like 200 webpages if you want to change the header?
Not with purely html no,
However with a little php you could.
Create a Header.php and put your header code in there.
each of your .html files becomes a .php
so you can then do
<?php include('Header.php'); ?>
Now any time you change Header.php every page gets the change.
Note: If your running this locally you will need a local "server" to run php, I personally use WampServer

"Universal" links in HTML? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Include one HTML file in another HTML file
On each of the pages on my website I have a footer that contains about 12 links. Every time I want to change a link, I have to do it on every single page. Is it possible to make it so I can somehow change the link in one place and it changes on every page? Thanks.
This exact problem is the beauty of serverside scripting, where you can define a header file that each page pulls from when it is retrieved, allowing you to change a single file and have the changes propagate your entire website.
This is what it could look like in PHP:
header.php - Link
all_other_pages.php - <?php include header.php; ?> ...
the better approach is use the mvc architecture for that . and you can do it by creating the separate php file and include them
like for header header.php for wrapper wrapper.php and for footer footer.php and to show a pagge just include or require them
like index.php
<?php
require"header.php"; // for the header of the page
require"wrapper.php";
require"footer.php"; // for the footer of the page
you can also make function of header() and footer() so you can also include many more function in a file and it reduce the amount of file also you only need to include the one file with function
index.php
<?php
require"function.php";
header(); // for the header of the page
require"wrapper.php";
footer(); // for the footer of the page
in above approach the code of header and futtor will be universal for all website what you need to change is the chande the code in wrapper.php
You don't need to do server side programming to fix this (though you can do), you can do it perfectly fine in the browser with a little javascript.
For example:
at the bottom of each page:
<div class="page-footer"/>
<script src="footer.js"></script>
in footer.js something along the lines:
$(".page-footer").append("<ul><li><a href='about.html'>About</a></li></ul>");
If you can use a server side include or other server side programming then yes, otherwise it isn't posible with straight HTML. You could include the footer in an IFRAME such that each page loads the same footer page, but this is far from an ideal solution.

How can I make a global header rather than pasting it in each page?

Every time I update my header, I go in and update each page individually. I'm pretty sure there is a way to keep the header in one file and just call it within each page.
This way I update one file and it's updated on each page automatically. I'm new in all this, so please keep it simple to understand :)
You don't say which server you are using to host the files - but most of them have the ability to do server-side includes. This would let you put your header into a separate file, and 'include' it in each html file. When the HTML file is requested, the server would replace the include statement with the contents of the header file.
Check your server documentation for more details
If your web host supports php, this is very very easy to do..
First create your header.php file and insert all the text, buttons and so forth in the header.php file.
Second create a footer.php file and insert all the text, buttons and so forth in the footer.php file.
Then create a index.php and call the include files like this.
<div><?php include 'header.php'; ?></div>
<div>Sone Content</div>
<div><?php include 'footer.php'; ?></div>
Then for the other pages follow the same guidlines. In order for this to work all of your files need to have a .php extension.
With seamless attribute your iframe tag would seems like part of your document:
<iframe src="header.htm" seamless="seamless"></iframe>
or
<iframe src="header.htm" seamless></iframe>
Just be careful about the browser support!

Repeat same HTML code in several pages

I have a really hard time searching for this, because I have no idea how to call it.
I'll try to describe the process I want, and see if any of you know such an editor.
I have a website that has the same html component repeated in them, for example, a menu. I can define how the menu looks with css, but I can't (as far as I know) add the same piece of html to every html page with a simple line.
What I do, is copy the menu over to every place. If I change the menu, I need to do it all again.
I know this can be achieved by using a dynamic server, with something like php or jsp, but I don't need it to be dynamic.
I was wondering if there was a way to do this.
I thought possibly there was an editor, where I can edit html using includes, and then "compile" the htmls after modification to produce the htmls I will replace on my server.
Thanks
Have a look at server side includes ... create a menu.shtml page and then include it like so :
<!--#include virtual="/menu.shtml" -->
Its supported by most web servers out of the box (including IIS, Apache and lighttpd)
Have you heard about MasterPage Concept
The below link will give you a quick start
Master page are pages which will act as a frame for all other pages. You have to write it only one. And each page that is coming under that, will have to include the master page. Thats all!
You can do this with jquery
Assume you have page1.html page2.html etc.
You want in each of these pages your contactinfo. You can create a file with the name "info.txt". On the spot where you want this contact info, you put a div. as shown in this example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
</head>
<body>
<!-- page content -->
<div id="contact"></div>
</body>
</html>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#contact").load("info.txt");
;
});
</script>
Whatever you place in 'info.txt' will be put on the spot of were you put
You could write a simple bit of js in an external file and then call it in each page to dynamically load the menu. You can then simply edit the menu by editting the JS file. all you'd need to do then is include the in the html and use document.getElementById("menu").innerHTML = menuHTML; where menuHTML is a variable containing the pure HTML code of the menu. You can then include the JS file and call it in the body onload