You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The project's location in my staging environment and production environment differs, so I cannot hardcode the full path within the Buttonbox config. I wish to use multi-environment variables, as described in the Craft CMS docs.
I have a multi-environment variable called basePath, which points to the project's root folder (some/folder/to/project/craft) on my staging server. On my production server, the path might differ (some/other/folder/to/project/craft).
When using multi-environment variables, as described in the docs, Buttonbox just urlencodes the variable. Let's say my general.php says that 'baseUrl' => 'http:/www.some.site/some/folders/to/project'. So when I enter {baseUrl}/admin/resources/images/icon.png, it should render http:/www.some.site/some/folders/to/project/admin/resources/images/icon.png. But it renders it as %7BbaseUrl%7D/admin/resources/images/icon.png.
You don't need to provide full path to the project. You can have your icons saved in public folder. Lets say you have your icons saved in a files folder within public folder, then the path to the icon would be /files/icon.png. It would work regardless of your different environments setup.
We will definitely support environment specific variables in the future but I'm afraid won't be straight away as we have triggers field using URLs too.
In the meantime, you could fork this repo and implement your solution as a temporary fix.
Activity
haabe commentedon Oct 3, 2017
Here's what I did to buttonbox/templates/buttons/field.html:
Nav33d commentedon Oct 3, 2017
Hi Haabe,
You don't need to provide full path to the project. You can have your icons saved in
publicfolder. Lets say you have your icons saved in afilesfolder withinpublicfolder, then the path to the icon would be/files/icon.png. It would work regardless of your different environments setup.Hope that helps.
Many thanks
haabe commentedon Oct 3, 2017
Yeah, well our different server setups make use of the public root folder difficult, whereas we've been using the multi-environment variables.
I've provided you with an example code on how to handle it. It'd be nice to see it implemented.
Nav33d commentedon Oct 5, 2017
Hi,
We will definitely support environment specific variables in the future but I'm afraid won't be straight away as we have triggers field using URLs too.
In the meantime, you could fork this repo and implement your solution as a temporary fix.
Many thanks