leftblank Posted February 12, 2014 Share Posted February 12, 2014 Hi, I'm developing locally, but connecting to a remote database on my staging server, so I can see the correct content when I'm developing. All of my assets are uploaded through the admin on the staging server, and are therefore hosted on the staging server. When I refer to an asset in a template, it is looking for that asset on my remote machine, so I therefore want to tell it to prepend the URL of my staging server in front of every asset path. Is there some global place I can do that? I don't fancy having to manually paste in a URL variable before every asset call in every template. Thanks! Link to comment Share on other sites More sharing options...
chrizz Posted February 12, 2014 Share Posted February 12, 2014 How do you include your assets? Relative or absolute paths? Have you tried using base href? Otherwise take a look at site/config.php You can add your own config variables an use them everywhere (e.g. in a template wire('config')->yourVariable) 3 Link to comment Share on other sites More sharing options...
ryan Posted February 16, 2014 Share Posted February 16, 2014 Another option would be to add a small module that hooks Page::render and replaces the paths directly in the output... when running on localhost. It could replace it with something like this: public function init() { if(wire('config')->httpHost == 'localhost') { $this->addHook('Page::render', $this, 'hookAfterPageRender'); } } public function hookAfterPageRender($event) { $event->return = str_replace('/site/assets/files/', 'http://domain.com/site/assets/files/', $event->return); } 6 Link to comment Share on other sites More sharing options...
leftblank Posted February 16, 2014 Author Share Posted February 16, 2014 Lovely solution, cheers Ryan! 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