page.docRootPath bug!

I have a php file which is placed two levels down from the website root folder, that uses a Component to generate some of the PHP code:

webroot
    level_1_folder
        level-2_folder
            index.php
                (Component included in index.php)

In the Component hooks.js, the page property docRootPath is being returned as:

../../../

It should be being returned as:

../../

Currently this is causing an error in my PHP code, as a ‘required’ PHP file which is in another folder at the root level isn’t being found, due to this path being incorrect.

Editing the published index.php file and substituting the corrected value:

../../

corrects the issue.

I checked the published code in an index.php file (that includes the same component) residing in a level_1_folder, this correctly returns docRootPath as:

../

are you publishing to a sub-folder?

Can you share the hooks file or code you’re using to get the docRootPath?

I have tried to recreate the issue in a small project but failed to do as it works OK! :thinking:

The structure In Elements I had was like this:

The files on disk look like this:

I don’t want to wast your time looking at this, especially as I can’t easily reproduce it in a small project file as I can work-around the issue.

I have done this by moving the Events - View and Events - Edit pages up a level and now the docRootPath is being returned OK. They don’thave to be at a lower level, it just made the structure nicer.

If I manage to recreate the issue in the smaller project, I will update this thread.

ok, thanks for the update! Do let us know if you manage to replicate the issue :slight_smile: