You are here:  » How to add banner?

Support Forum



How to add banner?

Submitted by kempo on Thu, 2007-06-21 16:19 in

I am very new to price tapestry and did not understand how to show my banner via editing html/banner.php file.
Please help me...

Submitted by support on Thu, 2007-06-21 16:28

Hello,

Sorry for the confusing names - html/banner.php file is not for displaying adverts, it is the file that creates the title and sort order links on each page - banner is just an appropriate name that I chose for it.

If you want to put an advert banner on your site, the best place is in either html/header.php (put your code at the end) if you want the banner at the top, or in html/footer.php (put your code at the beginning) if you want the banner at the bottom...

Cheers,
David.

Submitted by genehig on Thu, 2007-08-30 20:44

David,
I am a real novice about php coding, etc. You say to put an advert at the top to put my code at the end of html/header.php; where exactly. the code at the end of header.php is

<?php
 
endforeach; endif; 
?>

<?php
  
if (file_exists("html/user_header_after.php")) require("html/user_header_after.php");
?>

does it really go after the ?>

sorry
but we all have to start somewhere.
thanx
gene

Submitted by support on Thu, 2007-08-30 20:48

Hello gene,

If you want to add PHP code, put it BEFORE the ?>, but if you want to add some HTML, put it after the ?> and it will be sent straight to the browser on every page!

For example, to add HTML, the end might look like this:

<?php
  if (file_exists("html/user_header_after.php")) require("html/user_header_after.php");
?>
<p>Here is some extra HTML - you can put your banner code here!</p>

Hope this helps,
Cheers,
David.

Submitted by genehig on Thu, 2007-08-30 21:22

thanks David,
The thing that attracted me most to your software was your excellent support as evidenced in the forum.
I will try your suggestion and see what happens. I might have to hire someone to help, can you reccomend someone?
Thanx
Gene

Submitted by genehig on Fri, 2007-08-31 04:25

David,
I cant believe that I did it, but I did. I now have a new look and feel. I now have multiple columns and randomly rotating header graphics. Take a look at {link saved} and refresh the page a few times. See how the headers change with each click. Works on every page. Look at the source view and see how I did it.

Question 1: How can I do the same thing with clickable banner ads instead of jpg headers (I just copied this code out of another site that I bought)?
seems like if I took each banner's Html and saved it as a PHP file, I ought to be able to do the same thing with these banner php files that this routine is doing with jpg images. What do you think?
Question 2: How can I move the search form over to the center? Just cant figure it out (I ain't a programmer).

thanx loads for your great help and script. I am close to being able to go live.

Gene

Submitted by support on Fri, 2007-08-31 05:48

Hello Gene,

You're correct - you can do exactly the same thing in PHP. If you make a folder called "banners", and in that folder you put the code that you want and save it in a PHP file called banner1.php, banner2.php etc. Then the equivalent PHP code to the trick you used for the jpg's would be:

<?php
  $num 
rand(1,12); // change 12 for the maximum number of banner PHP files you have
  
require("banners/banner".$num.".php");
?>

Regarding the search form - it is appearing in the center as I look at your site at the moment. Let me know if you need help to relocate it elsewhere...

Cheers,
David.

Submitted by genehig on Sat, 2007-09-01 00:35

David, I tried putting your code in and guessed (apparantly wrong) at what I should take out. I can't get it to work. It looks to me that it also needs a write command of some kind. Would you please look at the following code and tell me what to take out and leave in and where to put your code. Also the Searchform shows up ok for me in firefox but not in IE -- any ideas why?

the code:
{code saved}

thanx for our help
Gene

Submitted by genehig on Sat, 2007-09-01 03:30

David,
I figured it out and got it to work as you specified. Is there a way to use descriptive file names versus banner1, banner2 etc. I will have a lot of these and it will be much easier to manage if I can use the merchant name instead of banner1, etc. Some of these banners will be for special sales with a time frame and need to be replaced when the sale is over, hence the need to know which banner is for which merchant so that I can recognize and replace them.

thanx
gene

Submitted by support on Sat, 2007-09-01 04:53

Hello gene,

One way to do it would be to read the files in the directory, and then pick a random one, something like this:

<?php
  $filenames 
= array();
  
$dirHandle opendir("banners");
  while((
$filename=readdir($dirHandle))!==false)
  {
    if (
substr($filename,0,1)<>"."$filenames[] = $filename;
  }
  
$banner filenames[array_rand($filenames)];
  require(
$banner);
?>

Hope this helps!
Cheers,
David.

Submitted by genehig on Sat, 2007-09-01 13:38

David,
when I try the code I get an error
Parse error: syntax error, unexpected '[' in /home/genehig/public_html/factsninfo/tapestry/inc/top.inc on line 23

the line in question is
$banner = filenames[array_rand($filenames)];

looks like it is looking for another ]

appreciate your help
Gene

Submitted by support on Sat, 2007-09-01 13:41

Sorry Gene,

The $ is missing from the array name, it should be this:

$banner = $filenames[array_rand($filenames)];

Cheers,
David.

Submitted by genehig on Sat, 2007-09-01 13:54

thanks David,
I now get this error

Warning: main(banner4.php) [function.main]: failed to open stream: No such file or directory in /home/genehig/public_html/factsninfo/tapestry/inc/top.inc on line 24

Line 24 is
require($banner);

Submitted by support on Sat, 2007-09-01 14:05

Hi,

Sorry (again!) - it needs to be prefixed by the banner directory....

require("banners/".$banner);

Cheers,
David.

Submitted by genehig on Sat, 2007-09-01 14:39

thanx David,
That did it.
Any idea why my searchform is centered with firefox but not with IE?

Submitted by support on Sat, 2007-09-01 14:44

I would suggest using the tag as well CSS align, which should do the trick. It is probably because the element is considered as block level by IE under the doctype in use. For example:

  print "<center>";
  require("html/searchform.php");
  print "</center>";

Cheers,
David.

Submitted by genehig on Sat, 2007-09-01 16:33

Thanx David,
Where do I put this code?

Submitted by support on Sat, 2007-09-01 16:59

Hi,

Look in the current index.php for the require("html/searchform.php") line, and replace it with the above code.

Cheers,
David.

Submitted by genehig on Sat, 2007-09-01 21:21

David,
After all that work to get the banners to show like I wanted them to, (I have two banners on the same line, now the one on the left is not clickable while the one on the right is. To get the two banners, I used your code twice without a br between them.

Got any ideas how to make the one on the left clickable also?

Gene

Submitted by support on Sun, 2007-09-02 10:13

Hi Gene,

I can see the problem. In your source code, you have a comment:

<! below is the code for random banners

...but you have not closed the comment off, so the link code for the first banner is still commented out! That comment should really read:

<!-- below is the code for random banners -->

That should help!
Cheers,
David.

Submitted by genehig on Sun, 2007-09-02 16:06

Thanks David, that did it. I am going bak to all the routines I modified and chk to see where I need to close out the comments I added.

You are a great help. I appreciate you.

Gene

Submitted by genehig on Mon, 2007-09-03 18:31

David,
everything is working beautifully in IE but in Firefox the main site header is off to the left. How do i get it centered? It is centered in IE.

thanx
Gene

Submitted by support on Mon, 2007-09-03 18:37

Hi Gene,

Try the same trick described above - using both center and div align='center' around the content, for example:

<center>
  <div align='center'>
  *** YOUR HEADER CODE HERE ***
  </div>
</center>

Cheers,
David.

Submitted by genehig on Mon, 2007-09-03 23:10

That did it.
Thankee, Thankee, Thankee very much.

Submitted by genehig on Thu, 2007-09-13 21:01

everything is working almost perfect but; I seem to have screwed up the subheaders on the category, brand and merchant search pages. I made the changes as we discussed and now
it has extraneous letters showing up instead of the Merchant A-Z or Category A-Z etc. Could you look at the code and tell me what I did wrong?

This happened after I changed HEADER.PHP to show my look and feel.
site is http://www.factsninfo.com/tapestry

Thanx Gene

Submitted by genehig on Thu, 2007-09-13 21:04

also,
how do Make the detail display = 100% for page width. This was also changed when I introduced my look and feel. Now things are scrunched up a bit.
Gene

Submitted by support on Fri, 2007-09-14 09:51

Hello Gene,

The content of the green bar is defined by the variable $header["banner"]. However, if you have used the $header variable for something else you may have overwritten what was supposed to be in it. Check that this is not the case. If you're not sure, email me a copy of your modified header.php (reply to your reg code or forum registration email) and i'll take a look for you.

If you want to make the detail page 100% width but not the other pages, the easiest way is first to make the entire site 100% width, and then add code to reduce the pages that you do not want to be 100%. You could do this by in html/header.php by looking to see if we are on the product page:

<?php
  if (isset($product)) // this means we are on the detail page
  {
    print "<div style='width:100%;'>";
  }
  else
  {
    print "<div style='width:700px;margin:auto;'>";
  }
?>

Don't forget to close the DIV in html/footer.php:

</div>

Hope this helps!
Cheers,
David.