Hi,

I'm creating a website and I've ended up with about 10 pages. Each page has the websites name and something like a banner/header. I've entered the banner/header for each page. So if I decide to make any changes, I'll have to change all 10! Is there anyother way that I can do this? Maybe by creating it separately and entering it in the page through a link or something...?? I'm quite new :icon_rolleyes: ...

I would appreciate if anyone could help me out on this,

Thanks,
Sonya

Recommended Answers

All 10 Replies

Hi Sonya,

Most hosting providers allow quick access to server-side scripting in PHP.

For example, you follow the tutorial for beginning PHP at w3schools.com.

You write a php file that contains functions that place your hearder / banner / title; then you include that php file into the individual 10 or so pages, and call the proper function (one time); then you've only got to tinker with the first script when things change.

site.php

function set_home_page_title($string) {
  echo $string;
}
function set_page_banner($int) {
  if($int == 1) 
     echo '<img alt="" src="my_banner.jpg" />';
  else if($int == 2) 
     echo '<img alt="" src="my_other_banner.jpg" />';
  else
      echo '&nbsp;'
}

index.php (home page) <title><?php set_home_page_title("Welcome to my site!"); ?></title> about.php <div class="banner"><?php set_page_banner(2); ?></div> As you progress in web design, it becomes necessary to learn a few of these tools.

ok let me make it even easier for u. just design a page which only contains ur banner and that welcome note or wht ever u want. save it as a .php file. then in all ur page include that file at the header space. like this: <?php Include("header.php") ?>
header means ur page name ok and after tht whever u need to make a change just change it in the header.php or whtever u name it file. it will be changed every where . cheers.

If you don't have scripting abilities you may consider an external Javascript file. Take this example:
header.js:

function header()
{
document.write("MySite <a href='index.html'>Home</a> <a href='about.html'>About</a> etc. "); //Put the header code here
//Note when placing the header code, make sure you replace " (Double Quotes) with /" (Slash and then Double Quote). Ex. /"I have a dream/"
}

For the pages you want the header:
Simply put this between the <head> and </head> tags:

<script type='text/javascript' src='header.js'></script>

And place this where you want the header:

<script type='text/javascript'>
header();
</script>

I would reccomend the PHP, since it is server side (and not executed on the client's browser) if possible. Here's an example:
header.php (Place your header's code in here):

MySite <a href='index.html'>Home</a> <a href='about.html'>About</a> etc. <!-- This is just a sample. Replace this line with your code -->

For a page that you want to put the header simply type:

<?php include('header.php'); ?>

Just make sure PHP is enabled.
Best of Luck,
FlashCreations

Hi,


according to me best solution for is placing an image using class of id in css.

code is
{
background-image:path of image;
background-position: according to your requirement;
background-repeat:depend on your image;
}

after modifying this code i hope you will not face this problem in future

Thanks

Hi Shruti Sepra,

That is a good idea, but the thing is I have expandable drop down menus, can I still do that?!

<code><title>Home</title> </head><frameset rows="125,*"><frame name="banner" scrolling="no" noresize target="contents" src="Top.html"><frameset cols="170,*"><frame name="contents" target="main" src="links.html"><frame name="main" src="Sprot.html" marginwidth="10" marginheight="14" scrolling="auto"></frameset> </code>

Why not take the easy way out , i know it's not perfect scripting option but use frames in your index page to place your banner and menus in and let the other pages appear in the main-frame

Frames.

I did think of frames, but I've heard that they're not recommended...and when the user scrolls down, it's still on the page, and sometimes it's annoying if it takes up one third of the page.. but I guess if I cant' figure out how to do it with the answers given above, I'll just have to go with the frame or just copying and pasting and doing a lot of checking to make sure everything's working.....(sigh..)

Hi
Sonya2525,

use the css style if change in your css class then it will change in all your pages

Hi Siryal,

Thank you for your reply. I am using css style, that's why I have to copy and paste in all the pages so that it can take effect. Is there any special way that you might know of which a one time entry could be done??

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.