Skip to main content

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.

Metadata

Release files for django-cms-smartsnippets 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-cms-smartsnippets 0.1.3
File Size Uploaded
django-cms-smartsnippets-0.1.3.tar.gz 12.8 kB Details

Release files / django-cms-smartsnippets-0.1.3.tar.gz

Download URL django-cms-smartsnippets-0.1.3.tar.gz
Size 12.8 kB
Tags Source
SHA-256 checksum
How to use checksums
9c404a0c3e74678c2fd0b82670117398053b15936e1acf03aba1562233a52a80
BLAKE2b-256 checksum
How to use checksums
016b9395e12c61d6b26cf914ef8df28b8e49ae635f3e6100bceff70a7f0c4643
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.3 This release

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page