Saving some text as a variable

  1. #1
    brianhabby is offline Junior Member

    Saving some text as a variable

    Hi there,

    Is there a (simple) way to save a portion of text as a variable to be used throughout a website.

    For instance, I have a footer at the bottom of each page and sometimes want to change it. This gets really tedious after a while because I have to go to every page on the site to change the text manually. I know I can copy & paste the text but it is still a chore, and as the site gets bigger so the chore gets bigger, and it is easy to miss a page.

    If I could somehow store the text as a variable, then I would only have to change it once for it to be automatically updated on every page on the site.

    Any ideas

    regards

    Brian


  2. #2
    DevilsAdvocate is offline Elite Member
    If your server has PHP then create the web pages as .PHP pages, as opposed to .HTM(L). Then, use an php include statement to 'include' an external file containing the required text.

  3. #3
    HappyBeaver is offline Bea*ering Away!
    Or use CSS for your footers

  4. #4
    brianhabby is offline Junior Member
    Hi there

    Thanks for your comments guys,

    I thought I would have a go using PHP but haven't got round to it yet. I hope to do something this weekend. I'm know absolutely nothing about CSS.

    I'll let you know how I get on.

    regards

    Brian

  5. #5
    HappyBeaver is offline Bea*ering Away!
    Let us know how you get on. But the PHP version's pretty simple.

    Create a new webpage called footer.php and at the bottom of each webpage you want it to appear, call footer.php with code:
    Code:
    <?php virtual('/folder where footer.php is/footer.php'); ?>
    Last edited by HappyBeaver; 08-07-2007 at 02:36 PM.

  6. #6
    brianhabby is offline Junior Member
    I've actually done it...

    I couldn't make it work at first but eventually I did it. The trouble is I did that much messing around with stuff I lost track of some of my steps. I think the main thing is that I have to set file permissions to 755 and I had no idea how to do that and couldn't find anything in my FTP client about file permissions. Eventually, after some searching I discovered it is also called the CHMOD Value and my FTP client did have a setting for this.

    I suppose it's like most stuff, when you know how, it's easy, and actually it was. I've now done the same with the header.

    If anyone is interested the site is at www.bhall.co.uk - I know it's not the best site in the world, but it's mine

    Thanks for your help guys

    regards

    Brian

  7. #7
    HappyBeaver is offline Bea*ering Away!
    Tackle the Web with $5.99 .COM's from Go Daddy!
    Glad you've got it sorted The CHMOD relates to how you want your files accessed on the server. 755 means it has write access to those files

+ Reply to Thread