Jayson Wonder Posted February 22, 2007 Posted February 22, 2007 Hi, I may have confused people with my other post so I will ask again in a simple way. How can I display the banner ad funtion that part of the footer of my shop on other parts of my website (outside of the store)? Like on my main entry page or other pages that are not part of the store. I am not so great with php but I think I need to figure out how to make this code work on other pages. <?php if ($banner = tep_banner_exists('dynamic', '468x50')) { ?> <?php echo tep_display_banner('static', $banner); ?> Please advise, thanks in advance.
Velveeta Posted February 22, 2007 Posted February 22, 2007 Hi, I may have confused people with my other post so I will ask again in a simple way. How can I display the banner ad funtion that part of the footer of my shop on other parts of my website (outside of the store)? Like on my main entry page or other pages that are not part of the store. I am not so great with php but I think I need to figure out how to make this code work on other pages. <?php if ($banner = tep_banner_exists('dynamic', '468x50')) { ?> <?php echo tep_display_banner('static', $banner); ?> Please advise, thanks in advance. You'll need to establish a link to your osc database from those other pages, and pull down the banner ad data, like the filename, and then display the banner using that information... Otherwise, if you know your banner filenames already, you can just insert them into the markup of those other pages manually... Richard. Richard Lindsey
Jayson Wonder Posted February 22, 2007 Author Posted February 22, 2007 You'll need to establish a link to your osc database from those other pages, and pull down the banner ad data, like the filename, and then display the banner using that information... Otherwise, if you know your banner filenames already, you can just insert them into the markup of those other pages manually... Richard. Thanks, I think I understand. any example of how I can go about linking to that database? Do I need a script? Where can I find one or learn how to make one that works? I do know that names of the banner files but I want to call the banner function to make the banners show up as it has a random banner display feature and statistic tracking from the admin panel. Thanks,
Velveeta Posted February 22, 2007 Posted February 22, 2007 Thanks, I think I understand. any example of how I can go about linking to that database? Do I need a script? Where can I find one or learn how to make one that works? I do know that names of the banner files but I want to call the banner function to make the banners show up as it has a random banner display feature and statistic tracking from the admin panel. Thanks, If you include your application_top.php in your outside-the-oscommerce pages, it will automatically establish the database connection for you, and give you access to the same functions you'd already have in oscommerce, like tep_db_query and whatnot... Then you can just copy the banner code from the footer and paste it into your store, and in theory, it should work :) Richard. Richard Lindsey
Jayson Wonder Posted March 6, 2007 Author Posted March 6, 2007 If you include your application_top.php in your outside-the-oscommerce pages, it will automatically establish the database connection for you, and give you access to the same functions you'd already have in oscommerce, like tep_db_query and whatnot... Then you can just copy the banner code from the footer and paste it into your store, and in theory, it should work :) Richard. Can you tell me how I include the PHP code in my outside HTML pages or at least where to find this procedure?
Velveeta Posted March 6, 2007 Posted March 6, 2007 Can you tell me how I include the PHP code in my outside HTML pages or at least where to find this procedure? Include the application_top file in your outside pages (you'll have to either rename them as php pages, or else make some mod_rewrite rules in htaccess to rename them in the browser as html pages), and the application_top include portion you can find in pretty much every single php file that's in the root catalog directory, and copy its syntax... As for the php code for the banners, like I said, you can copy it straight from the footer file, which is located at includes/footer.php... Paste it right into your outside HTML pages and it should work fine, provided you've included the application_top file at the top of the file... Richard. Richard Lindsey
Jayson Wonder Posted March 9, 2007 Author Posted March 9, 2007 Include the application_top file in your outside pages (you'll have to either rename them as php pages, or else make some mod_rewrite rules in htaccess to rename them in the browser as html pages), and the application_top include portion you can find in pretty much every single php file that's in the root catalog directory, and copy its syntax... As for the php code for the banners, like I said, you can copy it straight from the footer file, which is located at includes/footer.php... Paste it right into your outside HTML pages and it should work fine, provided you've included the application_top file at the top of the file... Richard. Thank you truly for your help so far, I am still somewhat stuck though. Here is what I have done so far in case anyone can help me or point me in the right direction. I first created an .htaccess file in my site directory and changed permissions to 644. I think this will allow my server to parse php code in files with extention of .html. Here is what I have placed in that file: AddType application/x-httpd-php .html I then created this web page as a test and named it test.html. (I even tried a test.php but that did not work either): <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.o$ <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> Test Banner Page <?php require 'scripts/application_top.php'; ?> <?php if ($banner = tep_banner_exists('dynamic', '468x50')) { ?> <?php echo tep_display_banner('static', $banner); ?> </body> </html> I also placed a copy of application_top.php and placed it in a directory called scripts. Cant get it to work and I am not sure what is the problem. Thanks, I am trying but struggling with this basic task....
Velveeta Posted March 9, 2007 Posted March 9, 2007 Ahhhhhhhh I see what you're saying... when you said other pages on your website outside of your store, I thought you meant just standard pages that weren't part of oscommerce, but shared the same directory, rather than residing in another directory... So are these html files in another directory apart from your oscommerce directory? And if so, where are they in relation to your oscommerce directory? Richard. Richard Lindsey
Jayson Wonder Posted March 10, 2007 Author Posted March 10, 2007 Ahhhhhhhh I see what you're saying... when you said other pages on your website outside of your store, I thought you meant just standard pages that weren't part of oscommerce, but shared the same directory, rather than residing in another directory... So are these html files in another directory apart from your oscommerce directory? And if so, where are they in relation to your oscommerce directory? Richard. They are outside the osCommerce directory. They are located 1 level up from the shop. They are in the www directory. The shop is one level below, like: www/shop. Thanks,
Velveeta Posted March 10, 2007 Posted March 10, 2007 They are outside the osCommerce directory. They are located 1 level up from the shop. They are in the www directory. The shop is one level below, like: www/shop. Thanks, And in your code, are adding this to the top of the files? require('/shop/includes/application_top.php'); Or did you copy application_top to the root folder and then try to include it? If you did it that way, you'll run into problems with paths being off and it won't be able to find any of your configure.php, class, function, etc. files... I'm not positive that requiring it as /shop/includes/application_top.php will work either, but at least your configure.php file should be set with the catalog path as /shop/, so in theory it would prefix all of the oscommerce directories with that when trying to load them... Richard. Richard Lindsey
Jayson Wonder Posted March 10, 2007 Author Posted March 10, 2007 And in your code, are adding this to the top of the files? require('/shop/includes/application_top.php'); Or did you copy application_top to the root folder and then try to include it? If you did it that way, you'll run into problems with paths being off and it won't be able to find any of your configure.php, class, function, etc. files... I'm not positive that requiring it as /shop/includes/application_top.php will work either, but at least your configure.php file should be set with the catalog path as /shop/, so in theory it would prefix all of the oscommerce directories with that when trying to load them... Richard. Hey Richard, I have tired what you suggested. Here is the code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> Test Banner Page <?php require('/shop/includes/application_top.php'); '; ?> <?php if ($banner = tep_banner_exists('dynamic', '468x50')) { ?> <?php echo tep_display_banner('static', $banner); ?> </body> </html> Still does not work though. This is tough. Not sure what to do now.
Velveeta Posted March 11, 2007 Posted March 11, 2007 <?php require('/shop/includes/application_top.php'); '; ?> What's this extra part here? '; Right below the require statement? And what's happening when you run the page? Does it come up blank, or hang, or does it show the Testing part at least? What if you drop in an arbitrary echo statement somewhere? Like: echo "this PHP line executed...<br>"; Just to make sure the PHP stuff is actually being parsed... Richard. Richard Lindsey
Jayson Wonder Posted March 11, 2007 Author Posted March 11, 2007 What's this extra part here? '; Right below the require statement? And what's happening when you run the page? Does it come up blank, or hang, or does it show the Testing part at least? What if you drop in an arbitrary echo statement somewhere? Like: echo "this PHP line executed...<br>"; Just to make sure the PHP stuff is actually being parsed... Richard. Sorry, that extra part is an typo on my behalf. Now that I cleaned it up this is the code am trying to test now to see if the PHP is being parsed: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <?php require('/shop/includes/application_top.php'); if ($banner = tep_banner_exists('dynamic', '468x50')) { echo tep_display_banner('static', $banner); echo "Test Banner Page...<br>"; ?> </body> </html> It does not show up so I assume it is not parsing. I tried to put it in a .php file and it gives me this error this: Parse error: syntax error, unexpected $end in /var/www/html/test.php on line 11 Line 11 is the last line. Does not make sense at all to me. I am so lost and I really need to get this operational. Obviously the .htaccess file is not allowing the server to parse PHP but even so, it is not working as a .php. Any thoughts? Thanks,
Velveeta Posted March 11, 2007 Posted March 11, 2007 Sorry, that extra part is an typo on my behalf. Now that I cleaned it up this is the code am trying to test now to see if the PHP is being parsed: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <?php require('/shop/includes/application_top.php'); if ($banner = tep_banner_exists('dynamic', '468x50')) { echo tep_display_banner('static', $banner); echo "Test Banner Page...<br>"; ?> </body> </html> It does not show up so I assume it is not parsing. I tried to put it in a .php file and it gives me this error this: Parse error: syntax error, unexpected $end in /var/www/html/test.php on line 11 Line 11 is the last line. Does not make sense at all to me. I am so lost and I really need to get this operational. Obviously the .htaccess file is not allowing the server to parse PHP but even so, it is not working as a .php. Any thoughts? Thanks, Well, the unexpected $end error is because you're missing a closing brace } on the end of that if statement... You'll need the if line, the display banner line, and then the closing brace... Move that test echo statement outside of the if block altogether, so that it executes regardless of whether the if evaluated to true or not, then run it again, and then change it to an html extension and retest to see if it executes... Richard. Richard Lindsey
Jayson Wonder Posted March 11, 2007 Author Posted March 11, 2007 Well, the unexpected $end error is because you're missing a closing brace } on the end of that if statement... You'll need the if line, the display banner line, and then the closing brace... Move that test echo statement outside of the if block altogether, so that it executes regardless of whether the if evaluated to true or not, then run it again, and then change it to an html extension and retest to see if it executes... Richard. This is what I get when I do that. Warning: main(/shop/includes/application_top.php): failed to open stream: No such file or directory in /var/www/html/test.php on line 3 Warning: main(): Failed opening '/shop/includes/application_top.php' for inclusion (include_path='.:/php/includes:/usr/share/php') in /var/www/html/test.php on line 3 Test Banner Page...
Velveeta Posted March 12, 2007 Posted March 12, 2007 This is what I get when I do that. Warning: main(/shop/includes/application_top.php): failed to open stream: No such file or directory in /var/www/html/test.php on line 3 Warning: main(): Failed opening '/shop/includes/application_top.php' for inclusion (include_path='.:/php/includes:/usr/share/php') in /var/www/html/test.php on line 3 Test Banner Page... Hmmm.. can you confirm that that is the path to your application_top file? I had thought you said your osc store was in the /shop directory, which would make the application_top file in /shop/includes/application_top.php, unless it had been moved... You didn't move it instead of copying it the other day did you? I would imagine not, or else you would have noticed that your entire store broke at the same time :) Can you just confirm that directory path to your includes/ directory? Richard. Richard Lindsey
Jayson Wonder Posted March 12, 2007 Author Posted March 12, 2007 Hmmm.. can you confirm that that is the path to your application_top file? I had thought you said your osc store was in the /shop directory, which would make the application_top file in /shop/includes/application_top.php, unless it had been moved... You didn't move it instead of copying it the other day did you? I would imagine not, or else you would have noticed that your entire store broke at the same time :) Can you just confirm that directory path to your includes/ directory? Richard. Yes, the URL is http://mysite.com/shop the file for my site are in the www diretory and my store is at http://mysite.com/shop When I do a PWD from my shell this is the path: /home/blue/mainwebsite_html/shop/includes I also tried this. Make any sesne to you?
Jayson Wonder Posted March 13, 2007 Author Posted March 13, 2007 I think I have figured out the path issue. This is the error now: Fatal error: Call to undefined function: tep_banner_exists() in /var/www/html/shop/includes/test_footer.php on line 16 I think I understand why this is but how do i define the funtion and which funtion do I define? Thanks,
Velveeta Posted March 13, 2007 Posted March 13, 2007 I think I have figured out the path issue. This is the error now:I think I understand why this is but how do i define the funtion and which funtion do I define? Thanks, Hmmmm, how did you solve the path issue? Because if you've got that application_top file included properly, you shouldn't be seeing this error... The banner functions are loaded automatically when application_top is loaded... Can you paste your current version of your test file? Richard. Richard Lindsey
Jayson Wonder Posted March 17, 2007 Author Posted March 17, 2007 Hmmmm, how did you solve the path issue? Because if you've got that application_top file included properly, you shouldn't be seeing this error... The banner functions are loaded automatically when application_top is loaded... Can you paste your current version of your test file? Richard. I took a slightly diffiernet approached this time as I was really fustrated. I changed things around so that my test.php file attemtps to include the footer.php, which seems to be how the other pages in the site do it. Here is what I have in this new test.php file: <?php require('shop/includes/test_footer.php'); echo "Test Banner Page...<br>"; ?> I also had to edit the original footer.php file to get rid of the counter stuff and created a file called test_footer.php. I think there may be a problem with the DIR_WS_INCLUDES part. I was getting strange errors so I commented it out. I also realize now that there appears to be no inclusion of the application_top file either. In any case here is what I have. Perhaps you can give me some tips: <?php /* $Id: footer.php,v 1.26 2003/02/10 22:30:54 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ // require(DIR_WS_INCLUDES . 'counter.php'); ?> <?php if ($banner = tep_banner_exists('dynamic', '468x50')) { ?> <table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td align="center"><?php echo tep_display_banner('static', $banner); ?></td> </tr> </table> <br> <table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td align="center" class="smallText"> <?php /* The following copyright announcement can only be appropriately modified or removed if the layout of the site theme has been modified to distinguish itself from the default osCommerce-copyrighted theme. For more information please read the following Frequently Asked Questions entry on the osCommerce support site: http://www.oscommerce.com/community.php/faq,26/q,50 Please leave this comment intact together with the following copyright announcement. */ echo FOOTER_TEXT_BODY ?> </td> </tr> </table> <?php } ?>
Velveeta Posted March 18, 2007 Posted March 18, 2007 I took a slightly diffiernet approached this time as I was really fustrated. I changed things around so that my test.php file attemtps to include the footer.php, which seems to be how the other pages in the site do it. Here is what I have in this new test.php file: <?php require('shop/includes/test_footer.php'); echo "Test Banner Page...<br>"; ?> I also had to edit the original footer.php file to get rid of the counter stuff and created a file called test_footer.php. I think there may be a problem with the DIR_WS_INCLUDES part. I was getting strange errors so I commented it out. I also realize now that there appears to be no inclusion of the application_top file either. In any case here is what I have. Perhaps you can give me some tips: <?php /* $Id: footer.php,v 1.26 2003/02/10 22:30:54 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ // require(DIR_WS_INCLUDES . 'counter.php'); ?> <?php if ($banner = tep_banner_exists('dynamic', '468x50')) { ?> <table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td align="center"><?php echo tep_display_banner('static', $banner); ?></td> </tr> </table> <br> <table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td align="center" class="smallText"> <?php /* The following copyright announcement can only be appropriately modified or removed if the layout of the site theme has been modified to distinguish itself from the default osCommerce-copyrighted theme. For more information please read the following Frequently Asked Questions entry on the osCommerce support site: http://www.oscommerce.com/community.php/faq,26/q,50 Please leave this comment intact together with the following copyright announcement. */ echo FOOTER_TEXT_BODY ?> </td> </tr> </table> <?php } ?> If you've got no inclusion of the application_top file, then none of this code is going to work, because from the application_top file, the banner functions are included, the general functions that those functions call upon, like tep_db_query, are included, and the database connection itself is first established... so if the application_top file is not included, you're going to have to establish the database connection yourself, and rewrite those banner functions into your own file, rather than calling them from their function files, and using only standard php functions, rather than oscommerce functions... You really need to work on getting that application_top file included correctly, as it would make this whole process much easier... Richard. Richard Lindsey
Guest Posted March 18, 2007 Posted March 18, 2007 If you've got no inclusion of the application_top file, then none of this code is going to work, because from the application_top file, the banner functions are included, the general functions that those functions call upon, like tep_db_query, are included, and the database connection itself is first established... so if the application_top file is not included, you're going to have to establish the database connection yourself, and rewrite those banner functions into your own file, rather than calling them from their function files, and using only standard php functions, rather than oscommerce functions... You really need to work on getting that application_top file included correctly, as it would make this whole process much easier... Richard. Richard, you know a lot more than me, but wouldn't he have to redo his config file to get the application_top file into his root dir? I think the config is looking for everything in the /shop dir not his root. Dose that make any sense, or am I way off base on that?
Velveeta Posted March 18, 2007 Posted March 18, 2007 Richard, you know a lot more than me, but wouldn't he have to redo his config file to get the application_top file into his root dir? I think the config is looking for everything in the /shop dir not his root. Dose that make any sense, or am I way off base on that? I was thinking about that as well, and I'm not positive on how to answer it... I know that the configure file holds the path to the catalog, since many people leave it in /catalog/... However, I think it builds its file references based on that relative path, so for example, DIR_WS_CLASSES is DIR_WS_INCLUDES . 'classes/', DIR_WS_INCLUDES is 'includes/', and then when links are built with the DIR_WS values via tep_href_link, the link construction is started with something like: $link = HTTP_SERVER . DIR_WS_HTTP_CATALOG; which is going to prefix all of those directory paths with the catalog directory... Now... the thing that may make it go bonkers is the direct includes, things like in application_top.php, where it loads the box class, and the session class, and some of the other stuff, because rather than using the catalog prefix, it tries to directly include that file... I'm not exactly sure how that works, whether it tries to include from the currently directory or from the directory of the original file that makes the include call, but I think it may be from that original file, so in this case, it's the file in the document root rather than in the store directory... So yeah, you may be right there, and he may need to work out an alternate version of application_top to include in his document root file he's working with, one that includes with the catalog prefix before the DIR_WS_CLASSES or whatever... Or he could try making an alternate configure.php file for that, which would include the catalog prefix right in those definitions, and make an alternate application_top file that includes that alternate configure file rather than the default... Richard. Richard Lindsey
Jayson Wonder Posted March 18, 2007 Author Posted March 18, 2007 Ok, I understand what you mean, I have to have the application_top.php file included. I went back to this simple test.php file: <?php require('shop/includes/application_top.php'); echo "Test Banner Page...<br>"; echo tep_display_banner('static', $banner); ?> This is the error I get when I try to view the test.php: Warning: main(includes/configure.php): failed to open stream: No such file or directory in /var/www/html/shop/includes/application_top.php on line 29 Fatal error: main(): Failed opening required 'includes/configure.php' (include_path='.:/php/includes:/usr/share/php') in /var/www/html/shop/includes/application_top.php on line 29 Perhaps it is an issue with the configure.php paths... as bktrain suggests???? Thanks guys, I hope to get this to work soon. All the input is appreciated!
Velveeta Posted March 18, 2007 Posted March 18, 2007 Ok, I understand what you mean, I have to have the application_top.php file included. I went back to this simple test.php file: <?php require('shop/includes/application_top.php'); echo "Test Banner Page...<br>"; echo tep_display_banner('static', $banner); ?> This is the error I get when I try to view the test.php: Warning: main(includes/configure.php): failed to open stream: No such file or directory in /var/www/html/shop/includes/application_top.php on line 29 Fatal error: main(): Failed opening required 'includes/configure.php' (include_path='.:/php/includes:/usr/share/php') in /var/www/html/shop/includes/application_top.php on line 29 Perhaps it is an issue with the configure.php paths... as bktrain suggests???? Thanks guys, I hope to get this to work soon. All the input is appreciated! Yeah, it sounds like it's a path issue, try creating both a duplication application_top and configure.php file, and in the duplication configure.php file, make sure the paths to all of the DIR_WS_* definitions include the /store/ directory also, and then in the application_top.php duplicate file, make sure it's calling /store/includes/configure.php, and then include *that* application_top file in your new file you're making in the document root... Richard. Richard Lindsey
Recommended Posts
Archived
This topic is now archived and is closed to further replies.