Jump to content

Absolute / relative image path


Doc
 Share

Recommended Posts

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

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

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

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

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

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

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.

  • Like 3
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...