ian-cox / Kirby-Color-Picker

A simple color picker field for the Kirby CMS
MIT License
86 stars 13 forks source link

A field, that was not yet saved won't return the default color. #5

Closed ghost closed 9 years ago

ghost commented 9 years ago

In blueprint site.php:

fields:
  covercolor:
    label: Cover Color
    type:  color
    default: FFFF00

Calling to $site->covercolor() won't return the expected color #FFFF00 until the site fields are explicitely saved in the panel.

PS. Nice plugin. Thanks!

ghost commented 9 years ago

Sorry, it seems to be the normal behavior of Kirby - nothing to do with your plugin.

ian-cox commented 9 years ago

To get around this I style the element as I would normally with CSS. Then I create a CSS overrides snippet which I include in the just below my CSS file.

The snippet would look something like this:

<style>

<?php if(!$site->bgcolor()->empty()):?>
body{
   background-color: <?= $site->bgcolor(); ?>;
}
<?php endif;?>

</style>

I recently used this technique to created a portfolio theme for Kirby with a ton of custom settings. https://dribbble.com/shots/2121204-Vessel-Theme

The theme lets you customize just about everything. The background color, text color, link color, max number of columns, the aspect ratio of the grid images, wether they are cropped or not (uses masonry if they are not cropped) You can even upload a custom svg logo and change the color of it's fills from within the panel.

Hope that helps you!