Parametrizable Django CMS snippets.
Project description
django-cms-smartsnippets
smartsnippets is a django-cms plugin similar to the builtin snippet plugin but instead of allowing only plain HTML you can use any valid Django template syntax inside. When a smartsnippet is added in a page the user can provide values for all detected used variables. This is much more flexible than the standard snippet if you want to parametrize and reuse your static snippets.
Example
A simple smartsnippet using the Twitter profile example:
<script src="http://widgets.twimg.com/j/2/widget.js"></script> <script> new TWTR.Widget({ version: 2, type: 'profile', rpp: 4, interval: 30000, width: 250, height: 300, theme: { shell: { background: '#333333', color: '#ffffff' }, tweets: { background: '#000000', color: '#ffffff', links: '#4aed05' } }, features: { scrollbar: false, loop: false, live: false, behavior: 'all' } }).render().setUser('{{twitter_username}}').start(); </script>
Note the {{twitter_username}} variable used as a standard Django variable. When adding the smartsnippet in a page, the form will provide an input field where you can set a value of that variable.
Settings
There are three configuration variables available:
SMARTSNIPPETS_SHARED_SITES a list of site names defaulting to an empty list. All the sites listed here will share their smartsnippets with all the other sites as read-only. This can be Useful in a shared environment to enable code sharing.
SMARTSNIPPETS_INCLUDE_ORPHAN a boolean flag that defaults to True. If this option is enabled, selecting a site in the smartsnippet creation form is optional. If a smartsnippet doesn’t belong to any site it will behave as global and will be available in all sites. If set to False the user will be forced to link the smartsnipptes that he creates to at least one site.
SMARTSNIPPETS_RESTRICT_USER a boolean flag that defaults to False. This flag, if set, will limit the smartsnippets that a user can access based on his relation to sites trough the global pages permission system. This can be useful in a shared environment. By default a user can access all the smartsnippets in the system.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file django-cms-smartsnippets-0.1.1.tar.gz
.
File metadata
- Download URL: django-cms-smartsnippets-0.1.1.tar.gz
- Upload date:
- Size: 11.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d98b1cdd059fed68dc96b5fe29c896a3a7d14a3f01d2bd8b6a809d1b751493fa |
|
MD5 | d432a25df616a0e0bdd97ead5aa90bde |
|
BLAKE2b-256 | 806635067fe365eafdd83357f05e423cdc41bf9cd2e56d2b72dc2dabef775a7a |