Jump to content

<?PHP include virtual("root relative url"); ?>


irvine

Recommended Posts

 

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

 

 

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

Thats ok, go to bed. :D

 

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.

 

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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,

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

You got it ;D

 

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 ;D

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.