Jump to content

Another thread about paths when Bootstrapping PW


JayGee
 Share

Recommended Posts

Have read loads of similar threads but can't find the deifnitive answer. I'm bootstrapping ProcessWire into a Magento installation. Everything is working fine in terms of expected PW API functionality, however I cannot get the paths for images in the site work correctly.

ProcessWire is installed in a subfolder called 'pw'.

If I load the PW site directly e.g. visit mainsite.com/pw everything loads fine and all image paths are correct. If I load the parent site in the root folder with the PW bootstrapped page content rendered within it, the image paths don't contain the subfolder and so are broken. So I get

https://mainsiteexample.com/site/templates/img/test.jpg

instead of

https://mainsiteexample.com/pw/site/templates/img/test.jpg

I've tried updating the rewrite base in the .htaccess file but it doesn't seem to make any difference. Have also tried various settings in the config file to no avail. Wondering if rewrite base perhaps isn't working as intended because I'm behind a NGINX/Apache hybrid environment?

Link to comment
Share on other sites

Thanks @wbmnfktr - I did take a look at this and couldn't get anything working. I'm not sure at this stage if this is a server config issue my end or I'm not using ProcessWire as intended in this scenario. It seems to me that PW is grabbing site root from the parent page where the embedded bootstrap content is rather than the PW installation itself. Is this expected behaviour?

Link to comment
Share on other sites

Ah ha moment - I think I got it!

Setting the root url in the template seems to have solved the issue. Although I think as per your post @wbmnfktr there's possibly a less destructive/repetitive way to this in future if can get my head round it!

<?php $config->urls->root = '/pw/';?>

 

  • Like 3
Link to comment
Share on other sites

42 minutes ago, dragan said:

Can't you just use httpUrl instead of url?

That was my first thought too but it seemed to produce different output when bootstrapped vs loading as ‘native’ ProcessWire.

Although I’ve now solved it, my hunch is still the rewritebase option in htaccess wasn’t working as intended. It could be because of the NGINX Apache proxy setup.

For the record since I left the office for the day it dawned on me that the link @wbmnfktr posted above to Ryan’s updates on the customisable paths probably will work - but I think it may currently require the dev branch whereas this site is running master. 

Link to comment
Share on other sites

17 hours ago, matjazp said:

Interesting - I did try to call setLocation() from ready and init and both threw an error even though the blog post indicates they’re callable from there.

Edited by Guy Incognito
Typo that didn't make any sense!
Link to comment
Share on other sites

13 hours ago, Guy Incognito said:

For the record since I left the office for the day it dawned on me that the link @wbmnfktr posted above to Ryan’s updates on the customisable paths probably will work - but I think it may currently require the dev branch whereas this site is running master.

 

13 hours ago, Guy Incognito said:

Interesting - I did try to call setLocation() from ready and init and both three an error even though the blog post indicates they’re callable from there.

 

Which pw version are you running?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...