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.

Add banner to all pages automatically

Discussion in 'PHP' started by Lawsuit, Apr 17, 2005.

  1. #1
    I want to add banner to all pages automatically without having to edit the html of each and every page of my site.

    If you don't know what I am talking about here are some hosts that do what I am trying to do for my site:

    http://buicks.tripod.com/ (See how tripod adds a banner to all the pages they host -- that's what I want to do on my site but I made it have way to many pages to do it manually)

    http://harindar.freefronthost.com/ (See how the site has the hosts banner on the top)


    I really need to do this for my site since it is composed of purley HTML pages which I manually made by hand and they added up over the months so I need to be able to add the banner to all the pages, anyone help is greatly appriciated, this is the only forum I am posting this question in because this site has always been very helpful but I really need help with this question whenever someone who knows how sees it.

    Thank you very very much,

    John
     
    Lawsuit, Apr 17, 2005 IP
  2. fryman

    fryman Kiss my rep

    Messages:
    9,604
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    370
    #2
    How do you edit your pages? What program do you use?
     
    fryman, Apr 17, 2005 IP
  3. Lawsuit

    Lawsuit Banned

    Messages:
    347
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I use ftp, uh, php, mySQL, I don't know what you mean, I can use PHP if I want and I know how but my pages are mostly HTML. I can use PHP and mySQL though, I think thats what your asking. I am standing by my computer as this is very important to me so don't hesitate to reply back as soon as you read this.

    God bless you for answering so quickly fryman
     
    Lawsuit, Apr 17, 2005 IP
  4. fryman

    fryman Kiss my rep

    Messages:
    9,604
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    370
    #4
    If you want to write down on your home page "We have Dr Ego in this forum" what program do you use???????
     
    fryman, Apr 17, 2005 IP
  5. Lawsuit

    Lawsuit Banned

    Messages:
    347
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Wow, I am stumped here, let me see, I woundn't use a program, I would use notepad to type it in html -- is that the right answer? My host is PHP supported and mySQL supported. Sorry for being such a newb I think your writing it as easy as you can and I thank you but could you make a tiny bit clearer

    God bless you :)
     
    Lawsuit, Apr 17, 2005 IP
  6. fryman

    fryman Kiss my rep

    Messages:
    9,604
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    370
    #6
    Yeah, I'm just trying to figure out what could you do. You need to do a search-and-replace, but you can't do that on multiple pages with notepad. I use Frontpage, maybe someone here can suggest an easy program to do this?
     
    fryman, Apr 17, 2005 IP
  7. Lawsuit

    Lawsuit Banned

    Messages:
    347
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I think this involves mySQL and PHP to achive I am not sure...
     
    Lawsuit, Apr 17, 2005 IP
  8. fryman

    fryman Kiss my rep

    Messages:
    9,604
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    370
    #8
    Whats your site? Where do you want to do this?
     
    fryman, Apr 17, 2005 IP
  9. Lawsuit

    Lawsuit Banned

    Messages:
    347
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Just over the whole site but I want to make a directory our site with about 400 articles I wrote over the weekend about gaming (the site is PerfectGamers.net, the articles arn't uploaded yet) I want to upload the HTML articles and put a banner on the top of all the pages of all the articles but I don't want to have to open 400 .txt documents and paste in each one the code, because what if I want to change the code, then i am screwed, THANKS!
     
    Lawsuit, Apr 17, 2005 IP
  10. Lawsuit

    Lawsuit Banned

    Messages:
    347
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Well, that was a waste of good time, i wrote all those articles for nothing :(
     
    Lawsuit, Apr 17, 2005 IP
  11. fryman

    fryman Kiss my rep

    Messages:
    9,604
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    370
    #11
    Nah, there must be a solution, but like I said, I do my editing in a totally different way, I'm sure someone will give another solution, just give it some time, it is Sunday night and not many regulars are online right now.
     
    fryman, Apr 17, 2005 IP
  12. nevetS

    nevetS Evolving Dragon

    Messages:
    2,544
    Likes Received:
    211
    Best Answers:
    0
    Trophy Points:
    135
    #12
    Well, you have two options. One is to use a program like UltraEdit which can do a search and replace on multiple files.

    The other is to do something like this:
    Use Mod Rewrite to force all your pages to go through a wrapper php script.
    The php wrapper script should just insert your banner ad in a common place - like right after the <body> tag, or if there is a common string in all of your templates that you can search for and then insert your banner code there.

    It's tricky because if you haven't been using a common template for all of your pages, odds are that you'll have to find several different ways to insert your banner.

    In the co-op forum somewhere there is a how-to on how to get coop ads on html pages. Read that for a little bit of guidance.
     
    nevetS, Apr 17, 2005 IP
  13. Lawsuit

    Lawsuit Banned

    Messages:
    347
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #13
    Ok, thanks, I am trying UltraEdit, it's acting wierd, can you explain the Mod Rewrite a little more? Thanks!
     
    Lawsuit, Apr 17, 2005 IP
  14. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #14
    Just as nevets described it in his post - the client would request your original HTML file, you would match the path using a mod-rewrite pattern and rewrite the URL so that a PHP script would be executed instead. This PHP script would receive the name of the HTML file as a query string (e.g. /dir1/file.html > /php/banner.php?path=/dir1/file.html). This PHP script would have to find the right spot in your HTML using some criteria (e.g. a particular string or a sequence of tags) and insert your banner HTML there.

    Personally, I would use some automated tool, like sed or awk to rewrite all of your HTML to use PHP or SSI and designed the new HTML with banners in mind.

    J.D.
     
    J.D., Apr 17, 2005 IP
  15. antonaf

    antonaf Banned

    Messages:
    411
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    0
    #15
    You can use php include for this. To include your header on each page, of course the initial setup needs to be done, because the include script must be on each page, but once that is done you will be able to edit your header from 1 location and it will be changed on every site which you have included the ?php include script. Every page will need to be saved as .php. You can use the ssi for .html but each page will need to be saved as .shtml.

    If this is banner advertising then I suggest the free banner ad server PHPAdsNew.com. This will allow you to advertise banners/text ads across your entire site and manage it from one location. It has many features and can provide real-time stats to your advertisers. Again, the intial setup will be needed. I do not think there is an automated way to accomplish this initially. With most, initially some effort is needed on your side, but once everything is in place, things begin rolling.
     
    antonaf, Apr 17, 2005 IP
  16. fryman

    fryman Kiss my rep

    Messages:
    9,604
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    370
    #16
    Sure, he can use the include, he can use many things to call the banner, but whatever he uses he needs to change the code on his pages.
     
    fryman, Apr 17, 2005 IP
  17. antonaf

    antonaf Banned

    Messages:
    411
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    0
    #17
    you too fast! you got me while I was editing :)
     
    antonaf, Apr 17, 2005 IP
  18. Stin

    Stin Guest

    Messages:
    264
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #18
    The mod rewrite is gonna be too complicated and messy to keep up. Id suggest writing and header and footer and put them on every page.

    If you put the header and footer in a folder called /include/ you can have them put into the current page with:
    
    <? include($_SERVER['DOCUMENT_ROOT']."/include/header.php"); ?>
    <? include($_SERVER['DOCUMENT_ROOT']."/include/footer.php"); ?>
    PHP:
    on every page (header at the top footer at the bottom of course) and just put the coop code into the footer.

    You will have to add those two lines to every page somehow. Maybe just get busy copy/pasting and you will be done in a few minutes. I use the same method for every page on my site.
     
    Stin, Apr 18, 2005 IP
  19. Lawsuit

    Lawsuit Banned

    Messages:
    347
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #19
    Ok, thanks very much, where can I get that script that wraps PHP code on all the pages, you said it's called mod rewrite, I searched for it and no luck, I have way to many pages to rename and all that stuff, I just want something that will autoit for all my pages even if it has to do it each time it loads. That seems the best way to go for me, thanks!

    Please don't forget to link me to the mod rewrite script or type it please THANK AGAIN! God bless.
     
    Lawsuit, Apr 19, 2005 IP
  20. Stin

    Stin Guest

    Messages:
    264
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #20
    Apache mod_rewrite
    But seriously, just copy and paste the include for a footer and header. This is gonna just become a growing problem.

    but basically to use the mod_rewrite you need to write something in your .htaccess to forward all your pages to a php script that uses GET
    then program the php script to the HEADER and FOOTER into each document.
     
    Stin, Apr 19, 2005 IP