A django CMS plugin for managing CSS background styles
Project description
django CMS plugin for configuring background images in edit mode via CSS rules.
Requirements
Django 1.8+
django CMS 3.3+
Installation
In your Python environment run
$ pip install cmsplugin-css-background
This will install the latest stable version of the plugin package. To install the package’s latest repository snapshot run
$ pip install -e git+https://github.com/alexmalykh/cmsplugin-css-background.git@master#egg=cmsplugin-css-background
Then add the plugin to INSTALLED_APPS list:
INSTALLED_APPS = [
...,
'cmsplugin_css_background',
]
and finally, roll database migrations:
$ python manage.py migrate cmsplugin_css_background
Usage
Define a placeholder in your template this way:
{% with css_selector = '#some-element' %} {% placeholder 'some_element_background' %} {% endwith %}
The placeholder might be located almost anywhere, not necessarily within/beside the element you want to change background. But it is recommended to keep both together for convenience.
Optionally, you might add an entry for your placeholder to PLACEHOLDER_CONF settings dictionary to restrict allowed plugin types to CSS Background and assign a readable title to the placeholder’s dragbar instead of generated Some_Element_Background.
Add an instance of CSS Background from Generic plugin group to the placeholder in CMS admin.
The plugin is rendered as <style /> HTML element in-place, like this:
<style type="text/css">
#some-element {
/* here 'background-' CSS rules go */
...
}
</style>
There is a single template, located at cms/plugins/css-background.html and it takes a single extra context variable css_selector which defines the element(s) to assign background settings.
By default, background properties are rendered as a list of separate rules, but there is one-liner option too. To change the way plugin rendered override the plugin template and replace
{{ instance.as_separate_rules }}
with
{{ instance.as_single_rule }}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for cmsplugin-css-background-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8399081b86b93e3a8fa892740c35eec4b0a8755d753f9c6aed6fd53022bf4a64 |
|
MD5 | 7f60b0c1bc9db2b59499ceb6b02dd397 |
|
BLAKE2b-256 | 97327a84d39bc7ed00b7bd26bcc4e98527adc15b4903bbcf024ce8b59aa34ca6 |
Hashes for cmsplugin_css_background-0.1.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ffa24b0dd1c208a868b32bd6aa96dd76a29ae19be0abf9b5d19fd35290cf6c21 |
|
MD5 | ef48db828a2debfb4f4aca287dc0abf5 |
|
BLAKE2b-256 | 3001764e16e5d08e06ee51953dd2b9f3215c476823a8537d938e67183da54b73 |