Hello,
Is there an easy way to show differents files depending if site is on live or on local server, for exemple:
if site is on local: show style.css
if site is on live: show style.min.css
Thank you
Hello,
Is there an easy way to show differents files depending if site is on live or on local server, for exemple:
if site is on local: show style.css
if site is on live: show style.min.css
Thank you
You could include a config setting in your environment config.php
standard config.php
c::set('css', 'style.css');
live server config.example.com.php
c::set('css', 'style.min.css');
And in your header.php snippet
<?php echo css('assets/css/' . c::get('css')) ?>
perfect, exactly what I try to do. Please can I ask you how I can use c::get in this case :
<?php echo f::read($kirby->roots()->index() . '...') ?>
thanks,
In the same way:
<?php echo f::read($kirby->roots()->index() . DS . 'assets' . DS . 'css' . DS . c::get('css')) ?>
or, alternatively:
<?php echo f::read($kirby->roots()->assets() . DS . 'css' . DS . c::get('css')) ?>
You can also hardcode the filenames but switch between two modes using the βdebugβ config:
<?php $stylesheet = c::get('debug') ? 'style.css' : 'style.min.css'; ?>
<link rel="stylesheet" href="/assets/css/<?php echo $stylesheet; ?>">
With that, you can set your local instance with c::set('debug', true);
, but if you also want to test locally what would happen on the live server you can switch it to true temporarily.