Doc Posted March 16, 2017 Share Posted March 16, 2017 Hi guys, I'm trying to integrate into PW that external module I have on the website I'm building : https://www.docpaddock.com/paddockhero_freemium/ It's using a lot of dynamically built javascript url inside, for everything : buttons, actions, etc, etc (I didn't code that module myself) I tried to integrate it into the main website but it was a nightmare to find how those dynamically url are built to replace them with code like that : <script src="<?php echo $path_template?>/myAppDirectory/js/createjs-2015.11.26.min.js"></script> <div id="header"><img src="<?php echo $path_template?>/myAppDirectory/img/header.png"></div> Is there a way with PW to tell something like : "I want to load everything for this page from that relative directory './myDirectoryApp' ?" I'm ready to add something like that at the top of every page if needed. Actually my website is built like that : /templates/library /templates/js /templates/css /templates/myAppDirectory Any idea on that ? Thanks ! Link to comment Share on other sites More sharing options...
Tom. Posted March 16, 2017 Share Posted March 16, 2017 Hello, I can see it's using <canvas>, it's very likely that all the urls are set in Javascript. I can't find any documentation on how to change the URL, am I getting your question right? If you like to any documentation I'm sure I can help you further. Link to comment Share on other sites More sharing options...
Doc Posted March 16, 2017 Author Share Posted March 16, 2017 Hi Tom, I think so that most of the URL are set in javascript. Some are not, and I could easily modified them. I left this strategy when I understood that the application was dynamically building some URL in js. I could hack some Php in there but it would be very long. I'm comfortable with the PW documentation but did not find the way to tell to PW I just want to use relative link for that directory... Link to comment Share on other sites More sharing options...
ottogal Posted March 16, 2017 Share Posted March 16, 2017 Sorry, posted in the wrong thread. Sorry again, it was the right place. Because you referred to it in the following post, I try to redescribe what I proposed: Use a variable $my_path = $path_template . "/myAppDirectory"; and modify the code to echo $my_path . "/js/createjs-2015.11.26.min.js"; Sorry that it was not helpful - and to all for the confusion! Link to comment Share on other sites More sharing options...
Doc Posted March 16, 2017 Author Share Posted March 16, 2017 Hi @ottogal, Actually I don't want to use that way of doing thing because it would force me to find (and hack) all the links/path which are "hidden" in that application, and most of them are dynamically built with js. Those 2 ones you take as example are the ones I could easily fixed because easily found and "static" The other ones are built in js, and difficult to find, embedded in some code... Link to comment Share on other sites More sharing options...
kixe Posted March 16, 2017 Share Posted March 16, 2017 Are you looking for: $config->urls->templates $config->prependTemplateFile Checkout https://processwire.com/api/ref/config/ Link to comment Share on other sites More sharing options...
Doc Posted March 16, 2017 Author Share Posted March 16, 2017 Hi @kixe, I've just read the documentation related to your advice. I didn't know about the prepend functionality... But I can't see how it could help me on this one. Perhaps there is something to do with $config->url but I'm not sure. To sum up, I'd like that this application, loaded in my template page 'MyApp' runs without hacking the path/links in the code. I'm looking for something which could make my template page believes that it's local to the 'MyAppDirectory' which is in /template/MyAppdirectory The main page I'm loading is in /template/Myapp, as all my usual website pages are actually. Usually, for a standard webpage of the website, I put some "$path_template" in front of every <img src=".."> but here it's not possible / too complex to do. Link to comment Share on other sites More sharing options...
BitPoet Posted March 16, 2017 Share Posted March 16, 2017 It should be possible to do this by specifying a base: <base href="<?= $config->urls->templates ?>myAppDirectory" /> in the header of the page. That means that relative link behavior changes as any url that doesn't start with a slash will be searched inside myAppDirectory. 3 Link to comment Share on other sites More sharing options...
Doc Posted March 16, 2017 Author Share Posted March 16, 2017 Oh oh @BitPoet, sounds promising ! I'm going to try it asap and will post my feedback here. Thanks ! Link to comment Share on other sites More sharing options...
Doc Posted March 18, 2017 Author Share Posted March 18, 2017 @BitPoet YOU-saved-my-weekend ! It works... That was exactly what I needed big big thank you. Thanks to all of you for your ideas. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now