tripson Posted March 31, 2008 Share Posted March 31, 2008 Hi. I'm facing a problem with integration of osCommerce in my web site. I would like to use some functions in files which aren't in the root/home directory but in second/third/fourth/etc... level directories. i would like to include 'header.php' including file in some other files because of logoff/my account/checkout links and i would like to use buy links. and I don't exactly know how can I accomplish this in the easiest way. any hints? thanks, tripson Link to comment Share on other sites More sharing options...
shooter-boy Posted March 31, 2008 Share Posted March 31, 2008 You can simply use the PHP include function and go back up levels using the "../" prefix. EG: If you are in catalog/website/ and want to include a file from catalog/ you can use include('../FILE.php') etc. Where you might run into problems however is when the file that you are including uses functions declared within the osCommerce fileset. For this reason, it is often required to include application_top.php, and application_bottom.php just like regular osC pages. This however isn't that straight forward, since the application_top.php itself includes files with a relative path. These won't be available to it, and you will get errors. As you can probably tell, it is more trouble than it is worth really. I would suggest keeping all of your pages in the same directory. Then you can simply include whatever you like, and have no problems. Rob Rob Bell - Inspired Graphix Customising osCommerce in Australia, and the world! View my profile for web and email links. I'm sorry, but i cannot offer Free support via PM etc, and osCommerce forums prohibit me from putting any reference to paid support in my signauture. However viewing my profile may provide links to my website or something like that which you may find useful. Link to comment Share on other sites More sharing options...
tripson Posted April 1, 2008 Author Share Posted April 1, 2008 You can simply use the PHP include function and go back up levels using the "../" prefix. EG: If you are in catalog/website/ and want to include a file from catalog/ you can use include('../FILE.php') etc. Where you might run into problems however is when the file that you are including uses functions declared within the osCommerce fileset. For this reason, it is often required to include application_top.php, and application_bottom.php just like regular osC pages. This however isn't that straight forward, since the application_top.php itself includes files with a relative path. These won't be available to it, and you will get errors. As you can probably tell, it is more trouble than it is worth really. I would suggest keeping all of your pages in the same directory. Then you can simply include whatever you like, and have no problems. Rob yea i tried that before... and get errors... but, i found low-end and not very nice solution... i copied 'includes' map in every level of directories and... for now, its working fine :) Link to comment Share on other sites More sharing options...
arietis Posted April 1, 2008 Share Posted April 1, 2008 yea i tried that before... and get errors... but, i found low-end and not very nice solution... i copied 'includes' map in every level of directories and... for now, its working fine :) i wouldn't recommend that because now, if you need to make a change in your includes/ folder you will need to copy that change into two or three (or more) other folders, increasing the possibility of causing problems later. you said you had errors when your tried include('../../filename.php') ... what were the errors? it's better to fix that than to create more work for yourself by having multiple copies of your code. Link to comment Share on other sites More sharing options...
shooter-boy Posted April 2, 2008 Share Posted April 2, 2008 Yeah the problems are what i said i would expect. I agree with arietis, it is high maintenance what you have done, i would simply keep everything in the same directory. Rob Rob Bell - Inspired Graphix Customising osCommerce in Australia, and the world! View my profile for web and email links. I'm sorry, but i cannot offer Free support via PM etc, and osCommerce forums prohibit me from putting any reference to paid support in my signauture. However viewing my profile may provide links to my website or something like that which you may find useful. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.