I am currently working on HTML I want to ask a question about website development.I am developing a website in which the basic layout remains same like menu, side menu etc but only the content changes.Currently I have make separate .html file for all web pages.
Can any one tell me is there a way through which I can make a separate file having etc common to all and call it in my html file.I have heard about CSS but it will only change the style and layout.
thanks
If your HTTP (apache 2 and IIS do) server supports Server Side Includes then you can just include another HTML file :
<!--#include file="header.html"-->
your content
<!--#include file="footer.html"-->
no need for a server side language then - just plain HTML
This is very big topic to include in just one answer. SO I will give only the logical part.
Separate your template into multiple chunks like:
1. header.php
2. leftSidebar.php
4. rightsidebar.php
5. footer.php
Now, include these common part on your every page.
For example: index.php
<?php
include "header.php";
include "leftSidebar.php";
echo "<div>".$thedifferentpart."</div>"; //Change only this part on every other page you will create.
include "footer.php";
?>
NOTE: This is only a logical part, applying the concept on your code
Yes, your best bet is a server side language, as Adam said. Absolutely avoid using the old style html frames: they're deprecated, and cause a certain number of problems, both on the programming side and on google optimization.
By using a server side language, you'll still have entire pages, but they will be partially generated by php (or asp) by printing more files into one. For example:
http://www.php.net/manual/en/function.include.php
Bye!
Your best bet in the long term is to use a server side language like ASP.net or PHP
I don't believe that is possible, strictly through HTML. However, you could use server side scripting like PHP to get it done. What you're talking about is a template, and is used quite often. What you would want, is to have your menu items (and CSS) and your header/footer code in separate pages. This way, if you make changes to the menu, or header/footer, it would be reflected in all the pages (written with PHP) you have scripted with the template method.
You would need the menu.html, header.html and footer.html in a place accessible by your main page code. That is, you would use the template method to write the content of your pages.
A psuedo code example in PHP would be like such:
<?php
include('header.html');
include('menu.html');
echo "Your main content items here";
include('footer.html');
?>
Related
I am using Kentico and have noticed a weird css issue. After mocking my pages up in Dreamweaver I then create the page in Kentico, however I have noticed that some elements in Kentico are slightly misaligned.
I have tried copying the source from Kentico into Dreamweaver to see if I can fix the issue but Kentico still renders the content incorrectly.
Are you using Dreamweaver in design or split mode? if yes, turn it off and use code mode only.
I guess you have to compare structure of your HTML and Kentico output HTML. Kentico add a form tag by default which may cause structural issue with css. If you can provide both html, I can help
On Kentico (up to version 11) when you use portal engine or ASPX templates you have this shortcoming. Kentico adds excessive HTML markup on the controls it creates on order to provide hooks that will help the engine to perform actions. For example, Bizforms add multiple divs/spans around normal input tags. So, you have to adapt the CSS you have created to match the tags used by Kentico.
What is your template type:
ASPX page: You can copy your entire HTML code from Dreamweaver into your aspx page template and then work on your page.
Portal Page: You need to understand the structure and cannot replace entire HTML Code from Dreamweaver. You have to seperate your HTML code to insert DropZone for web parts and widgets.
Good Luck!
You will have to make some adaptation always from raw HTML and kentico. In your case you are using aspx model which makes it more harder as server level changes are not 100% compatible with raw HTML or client side code. If possible use portal engine with transformation which will be more like to like of raw HTML.
You must create a directory in CSS/Stylesheet
If you're using the CSS section of the Admin interface, check to see if you have any & signs at the beginning of any tags. Kentico doesn't seem to support this so might be breaking any classes that appear after it.
I am learning to program in HTML. I have multiple pages on my dummy website, all of them with the same sidebar. Now, the sidebar is hard-coded into each file; that means that if a small change has to occur, I have to change every file manually.
I believe this is not the best practice, but is there a better way to do it without using PHP or JavaScript?
Copy your sidebar HTML code to sidebar.php and include it with PHP include or require command:
require("sidebar.php");
Read more at http://php.net/manual/en/function.include.php and http://php.net/manual/en/function.require.php
How about an <iframe> this is the only way I can think of using just HTML
Whats Different between
<!--#include virtual="JS.htm" --> //note that in this method all JS files imported like below in JS.htm
and
<script src="myjavascript.js" type="text/javascript"></script>
The <!--#include virtual="JS.htm" --> is server side include, won't work without certain configurations and is included by the server there and then already whereas javascript's way is loaded into the page.
Server Side Includes (SSI) is a simple interpreted server-side scripting language used almost exclusively for the web.
The most frequent use of SSI is to
include the contents of one or more
files into a web page on a web server.
For example, a web page containing a
daily quote could include the quote by
placing the following code into the
file of the web page:
With one change of the quote.txt file,
all pages including the file will
display the latest daily quote. The
inclusion is not limited to files. In
this very example, on a server that
can run fortune, the output of it, a
randomly selected quote, can also be
included.
Server Side Includes are useful for
including a common piece of code
throughout a site, such as a page
header, a page footer and a navigation
menu. Conditional navigation menus can
be conditionally included using
control directives.
Source: WikePedia
In the first case the javascript file is included on the server side so it is included inline. In the second example the browser downloads the html file and then sends another request to the server for the javascript file.
First off the #include is used only in classic ASP and has no meaning in ASP.NET so you should retag your question. So when you include something it actually takes the contents of this file and puts it at the place where it should be included, so you end up with a single file downloaded to the client.
When you include a javascript file, the contents of the file are not placed inside the main script but the browser sends a separate request to fetch it. This is the prefered way of including javascript.
The include (SSI -- server side include) puts whatever's in js.htm inline while the script tag references an exterior file without putting it inline.
While the include saves load time up front, it doesn't allow the javascript to be cached by the browser, meaning it can actually be slower in the long run.
Generally, I'd suggest using the script tag referring to an exterior file.
I know that I need to add the tracking code snippet at the bottom of all my pages, but is there a central location to do this?
Or do I need to add this tracking code to all of my templates?
I guess that I could wrap the snippet in a user control, or external .js file, and reference it on each page, but is there a global footer somewhere? The site I'm working on has about 30-40 layouts, and adding it to each one would be a pain!
Thanks in advance!
Actually, the role of a Sitecore layout is exactly this; to act as a global file that all individual page templates "derive" from.
Normally you'd stick the analytics code into the master layout, and use Sitecore sublayout/placeholder techniques to construct the various page templates you need. You would not normally need more than perhaps one or two layouts for any device you are serving content to. And I guess for most sites, the only device in use is regular web content delivery.
That being said, what you could do, is have all the layouts inherit their codebase from a common base class (inheriting from Page), and inject the google code centrally from here. Would still require you to go through all layout files however.
I have not tried the module, I think that is codebehind version. I have made this in XSLT, its pretty fast and easy to make. I have footer.xslt where I put the code that simply checks if page you are standing on uses template that I want to index and does not belong to page names that I want to exclude. Then I have an item with a custom template for Google Analytics with following memo fields.
IncludeTemplates -field contains list of templates that I want to include for analytics :
ExcludeItemsNames -field for excluding pages by item name
contains($includeTemplates, concat('|',./#template,'|')) and not(contains($excludeItemNames, concat('|',./#template,'|')))
Remember #key and #template is always in small letters
If you run many domains don't forget to add pageTracker._setDomainName("www.example.com"); in analytics script so you can separate sub-domains etc. if they use same footer.xslt
Normally we consider the actual Google code as content. Within Sitecore we normally have a settings folder, something like /sitecore/content/settings. This exists outside the root of the site. Beneath this have a settings item with a plain multi-line text field, I think the field type is memo or something similar.
Afterwards create an XSLT that renders out the content of this settings item. Something like (assuming the field is called value in the setting item):
<xsl:value-of select="sc:fld('Value','/sitecore/content/settings/footerJavaScript')" />
You may or may not need to set the disable-output-escaping attribute.
Then on the aspx page that your pages use as the template add a control that looks at the xslt rendering:
<sc:XslFile runat="server" Path="/xsl/footerJavaScript" />
The reason that we normally keep the javascript as content is this allows the client to change the analytics code without having to contact us.
I'm new to creating html pages etc - but am using VS 2008 just for the editing/intellisense capabilities.
My problem is I have a pure HTML only website (no ASP.NET) and have a fairly extensive header that has to be used in every page. It's frustrating to change the header parts of the HTML across all pages every single time it changes in one. Is there someway I can sort of 'include' the header part HTML in other HTML pages without having to manually cut-paste all-over?
Please note - I'm not using ASP.NET, so I CANNOT and WILL NOT be able to use Master Pages. Is there some other technique is what I want to know - so that when I change the header template in 1 place, it gets reflected in all other. I thought of inline frames, but not sure if that's a crappy way to do that and if it affects SEO
Take a look at Server Side Includes
They'll allow you to edit your header in the one file, which will appear instantly on all pages that include the header file.
Yes, take a look at SSI. Server side includes are a simple way to tell your web server to insert various things at various points in your HTML page.
Example:
<html>
<head>
<!--#include FILE="head.html" -->
</head>
<body>
</body>
</html>
If server side includes don't appear to work as expected, try renaming the page with a .shtml file extension.
Some web servers require that you name your file ".shtml" rather than ".html" in order to enable the parsing of your file.