Nov 21, 2009

Adding Static Content To Website...

free web hosting
Open Discussion & Free Web Hosting > Computers & Tech > Designing > Web Design and HTML

Adding Static Content To Website...

WeaponX
I want to add some static content to my website and was steering towards using SHTML files and the #include method, but hesitated on it. I currently have a big handful of .HTM files and don't want to convert them to SHTML (even though it shouldn't be much of a bother). I just like them to be .HTM files (use to it).

Is there any way to do something similar like the Server Side Include method above, but with HTM files instead? Usually the SHTML code will have some line like the below in it:
QUOTE
<!--#include virtual="mypage.html" -->
So if I just change that mypage.html, it will change it for all my other files using that line. Just FYI, one thing I want to use this for is the navigation menus - so I don't have to do this for every single file if I make some changes in my menus...and no, I don't use frames biggrin.gif

Thanks.

 

 

 


Comment/Reply (w/o sign-up)

szupie
You can ues javascript to include a few lines of text, but it'd be very inconvenient.

First, make your external javascript file to include your menu:
CODE
<script src="menu.js" type="text/javascript"></script>

Just put that line of code in the pages that you want the menu to appear in.

Then, in your menu.js insert this code:
CODE
document.write('[I]<div id=menu><p>I/'m here!!!</p></div>[/I]')

That will make the javascript write the html code into your page. Change the code in italics into the code for your menu. You'll have to escape the quotes(') eveytime you use them by putting a / in front of it. That's why it's very inconvenient to use it.


I have to go now. If you want, I can tell you a way to use PHP to insert files into your pages. It's a much better way, but I don't know if you want it, since you said something about using html only? PHP can be inserted into html files and browsers will see them as normal html, so I don't see any problem in using them. (I use them to include file myself)

 

 

 


Comment/Reply (w/o sign-up)

WeaponX
Thanks for the reply szupie. I'll probably stay away from javascript for now.

Yes, if you can provide an example on how to do this using PHP that would be great.

The only reason I mentioned html files only is because Firefox seems to have problems with PHP files that have javascript in them. In my main page, I have a navigation menu in javascript and I remember changing my index.htm to index.php with some PHP code in it (used to pull my forum topics to display in main page biggrin.gif) and it doesn't show up at all in Firefox. Internet Explorer and Opera doesn't have this problem. So right now I think the homepage is really a shtml file using the SSI method.

I know some of the terminology here by researching them online, but really don't know much about PHP nor more "advanced" SSI methods. A simple example should be ok for me...just so I have a picture of how it works.

Comment/Reply (w/o sign-up)

cyborgxxi
Someone please answer me: what is static content?

tongue.gif Sorry, but I was a little desperate. I don't know so many vocabulary and computer terms on design and web development, so you have to understand tongue.gif

Man, I'm so fond of people who can code sad.gif

Comment/Reply (w/o sign-up)

szupie
If your browser doesn't display the PHP file properly, it's probably something wrong with the server. Go to your cpanel, and in the Advanced Tools section, go to Mime Types. Look for "application/x-httpd-php" in the long list, and make sure that it says ".php .php4 .php3 .phtml" after it. I'll tell you how to use the PHP method in another post in about 10 hours (when I get back from school).

cyborgxxi: Static content is content that does not interact with the client (the web users). A page about the news is static content. A flash game is not. I don't think this forum is static content either (I'm not sure).
EDIT: jlhaslip has a better explaination than me smile.gif . Look at the next post.

Comment/Reply (w/o sign-up)

jlhaslip
QUOTE(cyborgxxi @ Jan 19 2006, 05:48 AM)
Someone please answer me: what is static content?
*



"Static Content" is content on a web page that never (or rarely) changes. It only changes if you alter the content of the file and upload the new version, or use the cpanel text editor to edit it after it is uploaded. If the User requests the page several times, it will be the same result each time.
"Dynamic Content" is content which is constantly changing or is changeable based on a User's input. For example, using php to search a database and altering page content based on the search results is a dynamic process.

Comment/Reply (w/o sign-up)

szupie
I'm back, with instructions on how to use PHP for adding a menu on your pages.

OK, if your PHP configurations are correct, let's look at the actual coding. First, the basics of PHP: the server the contains your PHP file will parse your file as a normal HTML file. But when you put "<?php" inside your file, it would start parsing it as PHP code, until it find the text "?>", where it would stop. The concept is similar to (X)HTML, where everything inside a certain tag would be parsed according to the tag (Like words inside the strong tag would normally become bold). So,
CODE
<?php echo "Bob Saget!!!"; ?>
would make the server parse the PHP and print out "Bob Saget!!!" (without quotes). If you put
CODE
<strong><?php echo "Bob Saget!!!"; ?></strong>
, the server will first treat the strong tag as normal HTML (meaning it won't do anything), then when it sees <?php, it will start parsing the code and then sending it as HTML. Then, your browser would parse the HTML and display the elements inside the strong tag as bold, and you would see "Bob Saget!!!" in your browser (without quotes).

Now, the actual functions we're going to use: the include... Uh... *Goes to look up the correct word*... statement. The include statement can be used to include an external file inside your existing page (what a surprise!?). So suppose you have your menu file saved as menu.htm in the same directory as your other pages...
CODE
<?php include('menu.htm'); ?>
Put that code wherever you want the menu to appear on your page, and you're done. Or, almost done. You still have to make the menu.htm...

Inside your menu.htm, put in something like this:
CODE
Home<br/>About<br/>OMG A Page<br/>Bob Saget!!!<br/>I'm bored.<br/>More filler<br/>Stuff
If your menu is as basic as that, that's all you need in your file. If you follow web standards, use lists (ul) for your menu. You should not include the <html></html> tags in your file. It's a part of a bigger file, and it does not deserve individuality tongue.gif . But seriously. If you put <html> tags in, you'd have multiple of them in your file. That's not correct coding.

Extras:
1. You can also use the require statement instead of the include statement. With the Require statement, the file must be included in your page, or the server would send an error back to your browser. It's good if the thing you're including is crucial to the security your page, but for a simple menu, you can simply stick with include.
2. If there is one page where you want the menu to be displayed differently, e.g. making every word bold, you can put <strong> around the <?php ?> to make the whole menu bold.
3. If your file is located in a parent directory. No, make that a "grandparent" directory: change the file location to '././menu.htm'. Every "./" means a parent directory.


Fin.

Comment/Reply (w/o sign-up)

WeaponX
Thanks for that short "tutorial" szupie. Looks great and absorbed the material biggrin.gif

I'm sure PHP should work properly since I have the SimpleMachines Forum installed already. But will double check the settings.

It's in a way similar to the SSI method...Is there any problem using one method (SSI or PHP) over another? I want to make it as problem-free as possible because as I mentioned earlier, I did have some slight problems with my menu displaying properly when my index page was a PHP file (it's a .shtml page now). But I will definitely experiment with this and probably change all my HTM pages to PHP.

Just one more question. Any way to direct all HTM pages to PHP instead? Otherwise, I'll post a message on the site asking all users to update their bookmarks.

Thanks again.

Comment/Reply (w/o sign-up)

szupie
I haven't tried using SSI, so I don't know how different it is. But I'm sure that it would be as problem-free as PHP.

You can use javascript to redirect your users to another page just add the following line of code in your page and it'll redirect to whatever page you want it to go to:
CODE
document.location = '/thepageyouwant.php';
Or, you can make the server parse your .htm files the same as .php files too. To do that, go to the Mime Types in your cpanel, and type "application/x-httpd-php" in the Mime Type box, and "htm" in the Extension(s) box. That would make the server parse even the htm files, which would increase server load a little bit. If most of your .htm files do not have PHP code in them, I wouldn't recommend doing this. But if they all have PHP code in them, it doesn't matter.

Comment/Reply (w/o sign-up)

Hercco
QUOTE(WeaponX @ Jan 20 2006, 03:57 AM)
Is there any problem using one method (SSI or PHP) over another?  I want to make it as problem-free as possible because as I mentioned earlier, I did have some slight problems with my menu displaying properly when my index page was a PHP file (it's a .shtml page now).  But I will definitely experiment with this and probably change all my HTM pages to PHP.
*



SSI is a bit of an old technology to use. I don't have any factual knowledge but I believe it now is less commonly supported by web servers than PHP.

PHP is a still developing technology and so popular that I don't see it disappearing anytime soon, unline SSI. So definitely go for PHP includes, it will ensure that your code is working on any other server your site might be in the future. Oh and especially as PHP is a programming language unlike SSI you can later add some dynamic elements with it to the same page. It's rather inconvenient to try to mix dynamic content produced/included with different methods. As you mentioned that you have SMF forum running on your site, check out the page ssi_examples.php at your forums directory (access with browser). SMF has these nice little things that you can use on any page of your site. For example you could show the hottest discussion topics on your front page and so on. Check the examples and you'll understand. By the way, these elements are available for both PHP and SSI.

And one more final remark: PHP tends to run faster with includes than SSI. Not that it matters much though...

Comment/Reply (w/o sign-up)


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Similar Topics

Keywords : adding, static, content, website

  1. Freewebs And Piczo
    :) website thingys (3)
  2. Question Related To Website
    need Web page solution (5)
    I have some question in mind that need solution so please 1) What is benefit of using header and
    footer tag in our web page ? 2) How we can registered our website on any search engine? 3) Did I use
    animated image without flash in website.? 4) What is the correct way to display web page on center
    in any browser.? if we use css style ? I have little idea off all question answer but i need
    specific help so welcome. Thanks....
  3. I Need A Template For A Website
    (11)
    i need a template for a game wesite. im making a game website and need a web template thats easy to
    use....
  4. Website Navigation Hover Buttons Stick So Made Css Today
    need further help with tutorial from this site (7)
    Hi I made hover buttons to go into my friends website because frontpage didn't allow the text on
    their buttons to be left aligned. Anyway, I think they stick a lot and i'm not happy with them.
    I have read a lot of people don't like the time it takes for java applets to load either so
    thought I should try doing the navigation buttons with the CSS shown on this site. I was so happy
    when after following the instruction my buttons turned out fine but the probem is that they have a
    solid border around each button and i want my nav bar to look like it's under....
  5. Web Developing Software
    THe simplest software for buidling a good and reasonable website (16)
    Hi Everyone !! I want to make a website but I dont wanna use the conventional software
    like Frontpage or Dreamveawer cuz one has to be a web developer to creat a website using the above
    mention softwarez. since I know a bit of designing so I created my 1st website using photoshop but
    what I did is I design the whole page as an image and took it to frontpage and using the hot spot
    option, I hyperlink the image parts and thuss created my website but obviouslyyy... this is not the
    professional way of creating websites .you can check my website its URL is http://s....
  6. Centering A Div
    without having to center the content in it (19)
    I'm now rebuilding my website, and I have come against a problem of which I don't know how
    to fix it. I am using div tags (of course) but what I want to know is how to center the site,
    without having the text layout centered. Does anyone know how? I have not found any solutions yet.
    Thanks in advance. MediYama....
  7. Problem With Selecting A Textbox Content
    (0)
    What i want to do is to first enabled a disabled text box, and then focus and select all the
    contents of this text box after the user clicks on a checkbox, i have it working with simple HTML
    and Javascript but how can i do to get the similar result using the DOM??? For simplicity i only
    include this code that works: CODE <script type="text/javascript"> function
    toggle(formname,checkname) { var c="CantField"; if(checkname.checked==true) {
        checkname.value="on";     document.f .disabled=false;     document.f .focus();     document.f
    .select(); } else {     c....
  8. A Website
    what all do i need? (8)
    ok, as you may have seen in some of my other posts, i plan to make a text based online game. Well,
    i feel that while im still learning php, mysql, and javascript, it would be a good idea to start
    learing what i need for a website, i know you need a domian name but uh yeah lol. I thought if im
    gunna learn one thing to make something happen i might as well try to learn it all lol. What could
    go wrong? lol. Well thanks for your help. Thanks Zemon1....
  9. Preview Your Website In Ie From Non-windows Os
    (3)
    If you are using a non-windows based OS probably Linux or Mac OS may be even Solaris or OS/2, you
    can preview how you website or new site design looks in Internet Explorer. A site by Daniel Vine
    provides you this facility for free, Just head over to http://www.danvine.com/iecapture/ and
    enter your sites URL to preview. This site will automatically create a screen shot of your site how
    it appears in IE. Usually it will take longer to get a screenshot because always there will be
    thousands of such sites queued to be previewed. Post your comments and experiences.....
  10. Music Into A Website ?
    (9)
    im not sure if this is the right place to ask this, but since webdesigning people visit this forum,
    they probably have some answer for my question :] im making a own website and im looking for some
    backround music with the same style as http://www.batterydrink.com/pitlanegame some computer based
    chill music. i cant make this stuff myself since i dont have programs nor the knowledge to do music
    myself, so does anybody here know if there is a page or something found from the internet from where
    you can download songs (computer made songs) that you can use on your website....
  11. Testing A Website Design
    (6)
    I am currently design a website for this small hotel. I have never in the past made website that
    weren't for myself of for friends, so I want to make everything perfect becuase I'm going to
    earn a small bit of pocket money this time. This is currently my checklist of things that I will
    do, just to make sure the website runs nice and smoothly. - optimize graphics and photos for
    faster loading times - approximate loding speeds across diferent internet connection - make my HTML
    upto HTML 4.01 strickt (W3C checker) - use style sheet to control formatting of site,....
  12. Website Template Design Tutorial
    A tutorial about 3Column website creation. (0)
    http://www.pokemon.roxr.com/indiacalling/viewtopic.php?t=22 I dont know how to upload pdf files
    here. However I am placing the link. Please tell me how can I upload pdfs here. All of my tuts are
    in pdf format. Thanks. This isn't a tutorial by any means. You've simply posted a link
    to another site. Since this is your first time, you'll get off with a verbal warning only. But
    be careful in future. You are not entitled to make such posts in the Tutorials section, unless the
    post is a full-blown tutorial written by YOU. ....
  13. Program To Design Your Website
    Program to design your website (21)
    I have a few questions about desinging a site: What is the best program to desing a site? Question
    What program do you use to design nice pictures and banners? Plz give some info!! Exclamation....
  14. Cms Design Problem - Dynamic Vs Static Content
    Keyword availibility for search and ad-e (6)
    CMS Design problem - dynamic Vs static content - Keyword availibility for search and ad-engines
    Here is the problem I am facing. I want method so that context sensitive ads can be put on my
    webpages. I am on my way to create my own simple CMS. The basic structure is that, I would be
    using CSS for presentation. The database would be holding the content. I would use the PHP to
    fetch the content from database and then show the HTML to any requests that come. Now, if I plan to
    put it up as a dynamic serving pages, the context sensitve ads may not be able to home i....
  15. Questions About This Website/topic Page
    astahost topic page (1)
    Is there a way to see all of the available topics, perhaps an alphabetized list? I saw a topic
    earlier, replied to one of the entries, but cannot find the topic any longer. Thanks very much!....
  16. Need Help / Ideas With My Website Makeover
    in flash? (5)
    Good evening, i have heard at the 'site review' part of the forum that my site would be
    better if i made just one red box, and place my links to the other pages on my site at the top. So,
    i tought, maybe i could make a header, in flash orso? Does someone know a good program and/or
    tutorial to learn how to make one? Thanks, Michiel....
  17. A Need For Content Management System
    Design of a CMS (11)
    Here is what I felt I need - a simple content management system. I have a lot of things that I need
    to put on the web, and by now, I am pretty much tired of repetitively coding in HTML. So, I need to
    resort to a Content Management System (CMS). I know there are a lot of CMS around, a lot of free
    ones too. One that seems good being PHPNuke. But, as I said, I need a pretty simple CMS. Simple
    in the keyword. So, I thought about designing a system for myself. That would ensure that I would
    learn a lot during the process. So are there any resources that you would lik....
  18. Need Help In Designing My Website.
    (1)
    If your looking for some new websites to join then here are some for you to join: You can join my
    website here: Click here Or you can join my friends website at: Click here My website is under
    construction at the minute, but the problem i face is that i need people to help me construct it.
    First one to PM me can do it if you want to and when you do help me, afterwards i'll make you a
    member of staff. Currently my friends website is down but hopfully it will be up soon. At least
    make an attempt to write a short review on what you site or your friend's s....
  19. Music On A Website
    How? (6)
    Ok on my website (not the one listed on sig) i have a really cool load up page which takes about a
    minute. What i want to do is have a piece of music playing in the background but without the user
    having to click on anything. Like say they enter my website then imediatly the music plays 1.Is
    this possible 2.If so HOW?? thanks /smile.gif' border='0' style='vertical-align:middle'
    alt='smile.gif' /> ....
  20. Flash Music Player On Website
    (2)
    hi you guys. i'm looking for a way to create a flash based music player where it automatially
    plays a song and you can skip to other songs, adjust the volume and start and stop it etc. anyone
    know where i can find this info. i would like to create it myself like using swish or macromedia
    flash not use a template as i want it to look like my website. thanks in advance!!....
  21. Css Vs Xslt Vs Smarty Vs Other : What To Use ?
    what to use in a website (3)
    Well I am not trying to compare them all. I am asking which one to use in making a
    personal,extendible and nice looking website. Its a simple problem of keeping design away from
    content. I am trying to make a personal website which would eventually showcase all of these
    technologies (and more) but I was looking for one to stick with as the main design. If you have
    done a large project with these technologies I would certainly like to hear from you.....
  22. Looking For Free Software To Build Website
    (17)
    I'm looking for a free software for building my own website in Astahost.Is there any free good
    and easy to build software for building website without using HTML codes as just like building free
    website in tripod? Thanks, sunny. Topic title edited by: Rudy....
  23. Website Poll
    how to create a poll (4)
    does anyone have a good script for crating a poll on a website -----This is not a tutorial. The
    tutorials section is only for genuine tutorials. Moved from Tutorials section to Web Design and
    HTML.-----szupie ....
  24. Website Acting Up On Me
    What Am I Doing Wrong? (7)
    Okay, so I was working on my site and I noticed that I can drag and drop my frmaes. I don't
    understand why I can because I didn't add that script anywhere in my html. If you would like to
    see what I'm talking about please visit here . Right click the webpage and click view source.
    If you would like to test the drag and drop yourself clcik on the graphic or the marquee and drag
    it. It's not suppose to move though, even though it does. Please somebody try and help me. I
    would try with CSS but I'm not good with CSS at all, I only know HTML so . . .....
  25. Building A Website
    (39)
    Im a newbie & I need to make a web site for my group and i was wondering what software should i use
    to make a nice website like astahost.com I currently have dreamweaver but i do not know how to use
    it..please help me!....
  26. Website Templates
    where to find some good ones (13)
    Hi... I've been looking around the net looking for some good examples of free templates good
    when co-use with PHP. I think i've been to most sites but can anyone throw out some where you
    think they have a good selection, other than zymic, which was my first guess hehe. Thanks.....
  27. For Website Review - Read First
    this is not the correct forum. (0)
    Since a lot of the requests for website reviews get posted here, I figured I'd pin this topic.
    The correct forum to post about website reviews, lay-out reviews is here . Please do not post the
    requests for review here, we (moderators) move them anyway, so you'd spare us a lot of work
    /wink.gif" style="vertical-align:middle" emoid=";)" border="0" alt="wink.gif" /> While any issues,
    ideas, etc about design itself can be posted here, the review is done in a different subforum.
    ~MoonWitch....
  28. Starting A Website
    (16)
    looking to create a fairl nice looking site, what kind of programing should i look into? also a
    little advice on getting started would be much apreciated.....
  29. Best Ad Placement on a Website
    (18)
    Most of the websites that I currently visit all of ads of some type in their website design. I was
    also planning to ad a few ads to my website to help pay for a domain name and was wondering where I
    should place my ads. Where is the best location to place ads so that a lot of people will click on
    them? Is it on the top or bottom and what type of ad service do you recommend that I use? Thanks,
    Nisshutsu....
  30. WebSite Development and Management Tools
    (10)
    Astra Site Manager Astra SiteManager scans your entire Web site highlighting functional areas
    with color-coded links and URLs to unfold a complete visual map of your site. With this tool you
    can: pinpoint broken links or access problems, compare maps as your site changes, identify key usage
    patterns for improving web site effectiveness, and validate dynamically generated pages. Linkbot
    3.0 Linkbot is a suite of Web site management utilities that helps webmasters track down and
    repair problems on their sites. Linkbot can find and repair broken links, locate slow a....

    1. Looking for adding, static, content, website

See Also,

*SIMILAR VIDEOS*
Searching Video's for adding, static, content, website
advertisement



Adding Static Content To Website...

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com