1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Is it possible to

Discussion in 'HTML & Website Design' started by justme234, Aug 28, 2004.

  1. #1
    I was wondering if it is possible with php (or anything else but rather php) to somehow create a menu list that you want to appear on every page, and make it so if u want to add another link onto the menu u cuold do so without having to go through every single page and alter it?

    for example, i currently have a page with a table and the left column is my menu list, At the moment i have just got a template and am saving every page as something.. But then if i wanted to add or delete a link from the menu list, i have to go to every single page and change it. Is there some other way to do this?
    thanks..
     
    justme234, Aug 28, 2004 IP
  2. schlottke

    schlottke Peon

    Messages:
    2,185
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Yes, you would write it in as an Include.
     
    schlottke, Aug 29, 2004 IP
  3. Foxy

    Foxy Chief Natural Foodie

    Messages:
    1,614
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #3
    This is an include:

    <?php
    include("overall-top.html");
    ?>

    as is this

    <?php
    include("overall-footer.html");
    ?>

    Try it :)
     
    Foxy, Aug 29, 2004 IP
  4. Trance-formation

    Trance-formation Peon

    Messages:
    598
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #4
    All my navigation links are php includes... it makes life a lot easier:) If you want any help or advice, mail me
     
    Trance-formation, Aug 29, 2004 IP
  5. Owlcroft

    Owlcroft Peon

    Messages:
    645
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Also keep in mind that PHP scripts themselves can be included in .shtml files, something which can on occasion increase flexibility.

    For instance, you can ssi-include a php script that gives different results depending on the parms passed to it:

    <!--#include virtual="/myphpdirectory/mytop.php?toptype=1" -->
     
    Owlcroft, Aug 29, 2004 IP
  6. expat

    expat Stranger from a far land

    Messages:
    873
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #6
    ..don't forget that if you want to use include or any other php on a .htm(l) page you have to tell apache that htm should be raced through the php encoder. On the other hand there is no reason to not use .php except users are more inclined to trust htm / pdf pages.

    .. also be aware that dynamic pages are not cached e.g. a php page is rebuild each time it is requested. (there are caching methods available) this maybe an issue on a very busy site.

    M

    PS to have htm pages execute php you may need a .htaccess file with the following entries
    AddHandler application/x-httpd-php .htm
    ...for shtml
    AddHandler application/x-httpd-php .shtml
     
    expat, Aug 29, 2004 IP
    Lever likes this.
  7. Trance-formation

    Trance-formation Peon

    Messages:
    598
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #7
    This is the sort of thing I would liked to have known a year ago before I completely renamed my pages with php extensions LOL

    Is there any evidence for this? How many average web surfers look at page name extensions?
     
    Trance-formation, Aug 29, 2004 IP
    Lever likes this.
  8. Lever

    Lever Deep Thought

    Messages:
    1,823
    Likes Received:
    94
    Best Answers:
    0
    Trophy Points:
    145
    #8
    I've only just started using includes in PHP and originally tried specifying paths just relative to the root like /ssi/include.html but kept getting error messages. Then I found that to pull an include from a folder I have to specify the full path including the http... is this usual or possibly just a quirk of my current host?

    So what next? I change all my pages to PHP and set-up 301 redirects... is there a likelihood of dropping in the SERPS whilst the engines re-index the pages? Does 301 redirect cover the issue that all old inbound links will still work OK?
     
    Lever, Aug 29, 2004 IP
  9. Trance-formation

    Trance-formation Peon

    Messages:
    598
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #9
    I'd say that's a quirk.. <?php include 'folder/file.txt' ?> works absolutely fine for me.

    Judging from the above posts there is no reason to rename all your pages, just use .htaccess to ensure that your .htm pages are parsed for php (Damn I wish I had known that when I renamed all MY pages!!)
     
    Trance-formation, Aug 29, 2004 IP
  10. Lever

    Lever Deep Thought

    Messages:
    1,823
    Likes Received:
    94
    Best Answers:
    0
    Trophy Points:
    145
    #10
    Thanks Trance-formation, the path situation might change when I shift ISP; been looking for a decent PHP host for my image database so I'll do the long paths for now...

    ...and thanks for pointing out parse option... hangovers so often cloud the obvious ;)
     
    Lever, Aug 29, 2004 IP
  11. expat

    expat Stranger from a far land

    Messages:
    873
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #11
    first thing when switching to php check what your environment is

    a page with <?php print phpinfo ?> will show you all there is.
    I tend to print this one as reference.

    If path are not preset you can do so by using
    php_value include_path .:/path/that/you/want/to/use

    Best of luck
    M
     
    expat, Aug 30, 2004 IP
  12. Owlcroft

    Owlcroft Peon

    Messages:
    645
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Several points here.

    One: if you tell Apache to treat all your html pages as php, you are needlessly jumping the server load (and your site's response time). I say "needlessly" on the assumption that you do not need all or the vast majority of your pages to actually be php scripts.

    Two: as I remarked before, if you need a localized sort of result, you can ssi-include the output of a php script (which can be a sizeable chunk of HTML code) into an shtml page. Many php scripts are essentially an html page with a small bit of php script tucked in, doing some one fairly limited task; that is wasteful of resources.

    Three: php, to my understanding, will look for requested files to include relative to the current directory, which--unless you have explicitly reset it in php, which you can do--will be the home directory of the script. If you need a file myparms.inc and its in the same directory as the script, you would include('myparms.inc') to get it; if it happens to be in a subdirectory under the script's directory, say /junque, you would include('junque/myparms.inc') to get it. If it's in the parent directory of the script, you would include('../myparms.inc') for it. There is also a parameter you can set called the "include path", whose function is self-describing.

    The thing to do before jumping into playing with the shiny toys is to think out exactly what you want and need to do, then find the cleanest way to do it. Very often, a simple ssi-include of an html chunk is all that's needed (that's how I do most of my often-extensive footer material). Remember also that ssi can supply you with more than just file-includes: you can get the current date and time, the date and time the file was last modified, the date and time some other file was last modified (especially useful when using file includes--get the date/time of the included bit)--you can even "include" a command to be executed by the shell, whose output will show up in the page (such as, just for example, a directory listing). SSI can do logic, too, making if/then/else tests, and acting on their consequences.

    The Apache article on the topic repays reading.
     
    Owlcroft, Aug 30, 2004 IP
  13. mopacfan

    mopacfan Peon

    Messages:
    3,273
    Likes Received:
    164
    Best Answers:
    0
    Trophy Points:
    0
    #13
    This can easily be done with asp as well.
    <!--include file="filename.ext"-->
    Code (markup):
     
    mopacfan, Aug 30, 2004 IP
  14. expat

    expat Stranger from a far land

    Messages:
    873
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #14
    well I do slightly disagree....

    From the Apache conclusion...

    SSI is certainly not a replacement for CGI, or other technologies used for generating dynamic web pages. But it is a great way to add small amounts of dynamic content to pages, without doing a lot of extra work.


    Yes, there is a bit of server load but to parse a 40k htm code page takes next to nothing specifically since and if php is loaded as apache module.

    The only real problem I ever encountered was when the mysql engine is on the same server and sql access per page is heavy. Caching is than a potential alternative.

    For real world-wide delivery speed nothing beats content delivery systems. No problem hosting pages in US or CAD and expecting ultrafast delivery across US, Europe and/or far east but hat maybe another thread).

    In the times of quad 1024Mb web servers I'm afaraid I just go for convenience.

    M

    The other big advantage is one does not need to switch pages from .htm(l) to .php.
    I
     
    expat, Aug 30, 2004 IP
  15. Lever

    Lever Deep Thought

    Messages:
    1,823
    Likes Received:
    94
    Best Answers:
    0
    Trophy Points:
    145
    #15
    OK, so <?PHP print phpinfo ?> didn't work but the ISP had a page of info anyway so that's there for future ref.

    As for .HTM to .PHP in the .htaccess file, that didn't work, so I hunted for some other options - all slightly different but none worked. Just waiting for the ISP to get back to me with an answer on that one, shall post answer for info purposes. Thx all :)
     
    Lever, Sep 12, 2004 IP
  16. expat

    expat Stranger from a far land

    Messages:
    873
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #16
    I'm guessing but if you are on sun servers the setup is different and may well have to be made through the isp. I have on set of accounts that I run through Sun servers and there I face the same problem that Suns standard control panel is nit good enough for joe public thus the ISP needs to adjust it to my liking.

    cheers M
     
    expat, Sep 12, 2004 IP
  17. Lever

    Lever Deep Thought

    Messages:
    1,823
    Likes Received:
    94
    Best Answers:
    0
    Trophy Points:
    145
    #17
    Just had a response form ISP saying
    "We are running a Zeus Webserver which may put some constrictions on this type of htaccess instructions

    We are looking into this problem"


    OK, so that's 2 days response time - could have manually changed it all over and done a 301 redirect in that time.
     
    Lever, Sep 14, 2004 IP
  18. expat

    expat Stranger from a far land

    Messages:
    873
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #18
    ...two day response time... I would start to worry.... the text of the answer implies that it was the security guard answering....
    zeus is probably running on solarix (sun) the htaccess is slightly different to apache

    http://www.zeus.com/extra/docsystem/docroot/apps/web/docs/modules/htaccess/tutorial.html

    if you want to know (further down the page redirect)

    But they may well have restricted usage of htaccess and they have to do it for you.
    M
     
    expat, Sep 15, 2004 IP
  19. Lever

    Lever Deep Thought

    Messages:
    1,823
    Likes Received:
    94
    Best Answers:
    0
    Trophy Points:
    145
    #19
    Now that I'm getting slightly technical with my site I do think it's time for a change :) Lucky its a personal site and not a client's.

    Cheers for the info M, the epic continues...
     
    Lever, Sep 15, 2004 IP
  20. ian_ok

    ian_ok Peon

    Messages:
    551
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #20
    Sorry to bring an old dog back alive...but this post could just save me a whole lot of work....

    I'm after using php include....BUT

    Does this mean I'll have to re-name of my pages to php....I'm on a windows 2003 server...can move to Linux (I think/hope!)

    My testing only works when re-name a file .htm/.html to .php

    Ian
     
    ian_ok, Dec 5, 2004 IP