HTML refrences like CSS

Posted:
in Genius Bar edited January 2014
is there a way (without using frames) to get everypage on a site to use the same code without putting it into everything?



i have the basic setup of the left sidebar with HTML, JavaScript, and CSS that i want on everypage. Is there a way without copying and pasting this code, that i can just use it as a refrenc (like i think u can in CSS) so that everypage that loads as long as i have a code telling it to read from that page it will get the same setup...plus whatever i want to add to that actual page?

Comments

  • Reply 1 of 14
    willoughbywilloughby Posts: 1,457member
    Yes but you need a server side scripting language. PHP, ASP, JSP, Cold Fusion etc. All of these languages can do this very easily.



    For instance in PHP you could just insert this php code into the place where you want that HTML to appear



    <? include("yourNav.html"); ?>



    You could also set up server side includes if you're using Apache. Server side includes would allow you to do the same thing but in html, but it would basically be the same type of structure



    <!-- include file="yournav.shtml" -->



    The only problem with SSI is that all pages will need to be named .shtml unless you modify your apache config file to also process .html files with SSIs.



    Uhhh...I hope that didn't just confuse you. Any questions?
  • Reply 2 of 14
    ast3r3xast3r3x Posts: 5,012member
    well that was just too easy





    uh server side languages like that, which do you think if i were going to learn one would be easiest/most useful, i hear good things about PHP (which is what i used)





    THANKS again mn
  • Reply 3 of 14
    willoughbywilloughby Posts: 1,457member
    PHP all the way! But mostly because it works on every platform. You can get PHP for Windows, Linux and of course Mac OS X. Its free (as in open source) and most web hosting companies support it.



    If you want to get started with PHP and MySQL (a great free database) check out this guy's website:



    http://www.entropy.ch/software/macosx/welcome.html



    He has some nice installers for all the software you need to get rolling. I love this guy, he's my hero.



    Once you get everything installed, check out



    http://www.php.net



    You'll find everything about the language there including every single function that you can use (and there's a ton!). Otherwise just check google. There's about a million sites about PHP and they're all very useful.



    Good luck
  • Reply 4 of 14
    ast3r3xast3r3x Posts: 5,012member
    thanks i'll definatly be learning PHP
  • Reply 5 of 14
    ast3r3xast3r3x Posts: 5,012member
    can your recommend a good book to start PHP with?
  • Reply 6 of 14
    willoughbywilloughby Posts: 1,457member
    Quote:

    Originally posted by ast3r3x

    can your recommend a good book to start PHP with?



    PHP and MySQL Web Development

    By Sams

    ISBN: 0-672-31784-2



    Yes, its sitting right next to me



    If thats too big, expensive etc for you, than get anything by O'Reilly. I've never been disappointed by any of their books. But this PHP book has been great.
  • Reply 7 of 14
    ast3r3xast3r3x Posts: 5,012member
    thanks...i'm on my way to barnes and noble 2morrow
  • Reply 8 of 14
    der kopfder kopf Posts: 2,275member
    PHP is indeed THE way to go, especially if you want to be loyal to the platform. OTOH, in the outside world, many employers do require the use of ASP. Now, the good thing is that Apache is slowly exterminating IIS (microsoft), and PHP is of course the preferred server scripter for Apache (although Perl is pretty powerful and widely used).
  • Reply 9 of 14
    willoughbywilloughby Posts: 1,457member
    Quote:

    Originally posted by der Kopf

    PHP is indeed THE way to go, especially if you want to be loyal to the platform. OTOH, in the outside world, many employers do require the use of ASP. Now, the good thing is that Apache is slowly exterminating IIS (microsoft), and PHP is of course the preferred server scripter for Apache (although Perl is pretty powerful and widely used).



    ASP is actually on the way out and ASP.NET on the way in. If you're just getting started with Web Development on a Window's platform, than you might as well start with the newest technology and learn ASP.NET/C#.



    I work in a Microsoft shop (unfortunetly) and we just started converting all of our old apps over to .NET



    However, all of my freelance work is in PHP. It ends up being cheaper for the client and its so much fun to ssh to their server, fire up VI and code away.
  • Reply 10 of 14
    ast3r3xast3r3x Posts: 5,012member
    hmm...i always see asp, never really saw what asp code looked like...will PHP seems to be very functional and powerful, so i'll check out PHP first. Do you think after i get a hold of PHP that i should check out ASP.net or whatever
  • Reply 11 of 14
    willoughbywilloughby Posts: 1,457member
    Quote:

    Originally posted by ast3r3x

    hmm...i always see asp, never really saw what asp code looked like...will PHP seems to be very functional and powerful, so i'll check out PHP first. Do you think after i get a hold of PHP that i should check out ASP.net or whatever



    Well it really depends on what you're looking to do. Are you doing this as a hobby, side job, or looking to get into it professionally? If your answer is the first 2, don't bother. If you're answer is professionally than yes, look at ASP.NET as well.



    ASP.NET is a whole new world. Its not about scripting and throwing some code together to generate a dynamic web page. Its all Object Oriented Programming (OOP). You have a variety of languages you can choose from to create ASP.NET pages (like C++, J#, VB.NET) but the most commonly used one now is C#. Basically the same code you use to create an ASP.NET web page in C# you can use to create a windows application! (with just a little bit of reworking). Thats the power of the .NET framework.



    If you're already familiar with OOP, than C# should be pretty easy for you to pick up. If you're a programmer, or interested in becoming one, you should try to learn at least 1 new language every year. So yeah, any new skills you can get under your belt will help you out in the long run.



    Of course, none of this matters if you don't have a PC or access to one. You won't be able to do any .NET/ASP.NET programming on your Mac. But PHP is cross platform.
  • Reply 12 of 14
    willoughbywilloughby Posts: 1,457member
    In case you were wondering....



    PHP:

    Code:




    <html>

    <body>

    <? echo("Hello World"); ?>

    </body>

    </html>









    ASP:

    Code:




    <html>

    <body>

    <% Response.Write("Hello World!") %>

    </body>

    </html>









    ASP.NET using C#

    Code:




    <%@ Page Language="C#" %>



    <script language="C#" runat="server">

    void Page_Load()

    {

    lbHelloWorld.Text = "Hello World";

    }

    </script>



    <html>

    <body>



    <asp:label id="lbHelloWorld" runat="server" />



    </body>

    </html>





  • Reply 13 of 14
    ast3r3xast3r3x Posts: 5,012member
    i am doing it for a hobby...i know extremely little javascript, and basic c++



    i like to design web stuff and would like to get into more then just the look and be able to control what they do more
  • Reply 14 of 14
    ast3r3xast3r3x Posts: 5,012member
    i got "Programming PHP" from O'Reilly so hopefully it will work for a novice PHP person like I...it seems like it will so far at least





    thanks for the help all
Sign In or Register to comment.