irvine Posted March 24, 2008 Share Posted March 24, 2008 I am fairly new to PHP so this is probably a bit basic. I am using Zen Cart as a module of a larger site and using <!-- comment out supplied headers/menus --> <?PHP include virtual("root relative url"); ?> <!-- My stuff --> <!-- return to zen cart header... --> I have redirected all the headers and menus of the Zen Cart module to my headers and menus. This works! No Problems When I go onto my main index page and use exactly the same line of code, the header and footers are sent out to the browser, So it is working!. But, I am also getting the following error messages Warning: include(1) [function.include]: failed to open stream: No such file or directory in C:\xampp\htdocs\my-site\index.php on line 11 and Warning: include() [function.include]: Failed opening '1' for inclusion (include_path='.;C:\xampp\php\pear\') in C:\xampp\htdocs\my-site\index.php on line 11 Could somebody please explain what the problem is and why I don't get the error messages when the functions are call from inside the Zen Cart module Quote Link to comment Share on other sites More sharing options...
uniflare Posted March 24, 2008 Share Posted March 24, 2008 give us the erroring lines and a few lines above/below that Quote Link to comment Share on other sites More sharing options...
irvine Posted March 24, 2008 Author Share Posted March 24, 2008 Thanks for the quick reply, this is the page in total. Once I sort out the problem with headers and footers, I will use this as a page template and fill in the blank bit between the PHP includes. <html> <body style="color: rgb(0, 0, 0); background-color: rgb(0, 0, 0);" alink="#000099" link="#000099" vlink="#990099"> <table style="text-align: left; background-color: rgb(192, 192, 192); width: 100%;" border="0" cellpadding="2" cellspacing="0"> <tbody> <tr> <td style="background-color: rgb(192, 192, 192);"> <?php include virtual("/new-site/includes/header.shtml");?><br> <br> <?php include virtual("/new-site/includes/footer.shtml");?></td> </tr> </tbody> </table> </body> </html> I get the same error messages for both lines of PHP, so I didn't post the errors for PHP include footer Basically, I am trying to get both the Zen Cart pages and my pages to have the same look and feel, ie seamless integration. Quote Link to comment Share on other sites More sharing options...
ryeman98 Posted March 24, 2008 Share Posted March 24, 2008 I'm a little tired right now so I don't want to have you do something that doesn't work but I know that you'll need to figure out the paths. /new-site/includes/header.shtml will work fine when you're on htdocs but as soon as you go to a different folder, it will try to find the file from there. Quote Link to comment Share on other sites More sharing options...
samshel Posted March 24, 2008 Share Posted March 24, 2008 I think if your files are distributed in different directory levels than using absolute path is a better option. Best thing to do would be to define a constant for the absolute path in a config file which is included in all files and use that constant to specify paths for include files. hth Quote Link to comment Share on other sites More sharing options...
irvine Posted March 24, 2008 Author Share Posted March 24, 2008 Thats ok, go to bed. I thought the point of root relative was that so long as the site was built and structured inside one folder, it did not matter where inside the folder header.shtml was called from. Roughly my site map would be: new-site/ index images/ mystuff/ zen cart/ end (site map) On my main server, the structure is my-ip-address/ site-1/ site-2/ "" "" new-site/ end (my-ip-address) So Iff it is structured properly, all I need to do is copy the "new-site" folder directly onto my main server. Quote Link to comment Share on other sites More sharing options...
irvine Posted March 24, 2008 Author Share Posted March 24, 2008 Slight edit of site map. new-site/ index images/ includes/ mystuff/ zen cart/ end (site map) Quote Link to comment Share on other sites More sharing options...
irvine Posted March 24, 2008 Author Share Posted March 24, 2008 I am sorry like, but I am now very confused. I have spent quite a long time today google-ing various combinations of : Tutorial, PHP, constant, absolute, virtual, path, config, include, file..... I am sure you get the picture. :-\ Noting: 1) I don't know where in Zen Cart my headers and footers are called from. AND 2) The only fixed reference point that my-stuff and zen-cart have in common is the site root directory. The only two possibilities, that I can see, involve either: A) At some point calling a file that is relative to the root. OR B) using auto_append to attach my-constants.php to every php file on the server. I don't think that using auto_append is a good idea, just on my folder of the server alone I have got a couple CMS already and Zen Cart will be a third. Like I say I am new to PHP and at the moment, I am even more confused than I was this morning. So I am expecting somebody to tell me I have got this totally wrong and apologize in advance. Quote Link to comment Share on other sites More sharing options...
uniflare Posted March 24, 2008 Share Posted March 24, 2008 sounds like your going to need help from someone who can access the script or has done this before. i havn't done this before but pm me if you want me to see what i can do with access to the server. just dont give out any private info on this board, best sent thru email or messenger. --- Generally i would look for an original zencart template file, copy it and change it as needed. Quote Link to comment Share on other sites More sharing options...
irvine Posted March 24, 2008 Author Share Posted March 24, 2008 When its called from inside the Zen Cart module it works fine, absolutely no problem! The problem is that when I call it from outside of the Zen cart module, as illustrated, it works in the sense that it prints out the required header and footer, but I also get two error messages for the include and virtual functions. Its the script that I have pasted that is causing the problem Quote Link to comment Share on other sites More sharing options...
uniflare Posted March 24, 2008 Share Posted March 24, 2008 erm, could you not just use "include('./new-site/includes/header.shtml');" i dont know why you are using virtual for simple path recognition. ive never used it and never needed it. i dont see why you would. from my understanding you would either use include OR virtual and not a combination of both. http://uk3.php.net/virtual hope this helps, Quote Link to comment Share on other sites More sharing options...
irvine Posted March 24, 2008 Author Share Posted March 24, 2008 Nah, I just tried that to check but it doesn't work. I lose the header and footer. From what I was reading include virtual is much more versatile and so if there is any doubt, include virtual is the one to use. This link http://www.boutell.com/newfaq/creating/include.html why. Quote Link to comment Share on other sites More sharing options...
irvine Posted March 24, 2008 Author Share Posted March 24, 2008 Since there seems to be some confusion about where the error is originating, I have posted a couple screen shots onto the construction page of my new site at http://www.scottishpics.co.uk/ you need to scroll down to see them, the first one is from inside Zen cart and the second is from the main index page outside Zen cart. They are both calling the same files from the same root relative url. ??? I may have to go to bed soon, I have been at this for over 12 hours today Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted March 24, 2008 Share Posted March 24, 2008 i'm with uniflare. from php manual for virtual: "This function may be used on PHP files. However, it is typically better to use include() or require() for PHP files." what do you hope to gain by using virtual? Quote Link to comment Share on other sites More sharing options...
uniflare Posted March 24, 2008 Share Posted March 24, 2008 hes using virtual to include .shtml file, not php. since most shtml directives need to be on .shtml files, he is including a .shtml file to be parsed inside a .php file (from what i understand). Quote Link to comment Share on other sites More sharing options...
uniflare Posted March 24, 2008 Share Posted March 24, 2008 i would suggest only using virtual and not include. from what i understand virtual is sorta like and include function in itself. Quote Link to comment Share on other sites More sharing options...
irvine Posted March 25, 2008 Author Share Posted March 25, 2008 You got it It was the include function that was causing the problem, virtual on its own works. I was labouring under the misapprehension that virtual was solely a boolean. Yes I am including a .shtml file to be parsed inside a PHP file. Zen cart is written in PHP, which I want to learn, But designing pages is much easier with a WSYG editor in Html. I was using a combination of Seamonkey, Text Rep and Notepad2, but it Seamonkey cant handle PHP so I have just changed to NVU. The reason I am using root relative is so that I gain portability. When I tried using just the include function, I lost all output. I still don't see why include virtual should work inside the zen cart module and not work when called from outside, since the header.shtml is outside of the Zen cart module :-\ Anyway thanks, it just goes to prove that you learn a lot more when things don't work Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.