mirskutils.contentblocks

There are numerous django-based content management systems[1]_[2]_ available, providing full-fledged applications that stack up well against others in the industry drupal, wordpress, etc. However, often times a developer only needs to a developer only needs to enable an administrator to edit sections or snippets of content that are embedded throughout the web application. In this case, the existing CMSs are cumbersome and often assume that the application is based around them and not as a component to another web application.

ContentBlocks are intended to be a simple way of providing “static” editing capabilities to a user without giving the capability of mucking with the site’s style and layout.

  • one or more paragraphs of text (limited styles to bold, italic, underline, lists)
  • playlist of videos
  • a series of images
  • a collection, in a ranked order, of other contentblocks
[1]https://www.djangopackages.com/grids/g/cms/
[2]https://code.djangoproject.com/wiki/CMSAppsComparison

Content Block Model

class mirskutils.contentblocks.models.ContentBlock(*args, **kwargs)

ContentBlock(id, title, slug, kind, category, content)

Template Tags

mirskutils.contentblocks.templatetags.contentblocks.contentblock_exists(slug, category=None)
Description:
Check to see if a ContentBlock exists and if it contains any content
Arugment(s):
  • ** slug ** (required) : the unique identifier for the block
  • ** category ** : taxonomy to organize blocks

Usage:

{% contentblock_exists 'contact-us' 'public' as ctnt_exists %}
{% if ctnt_exists %}{% endif %}
mirskutils.contentblocks.templatetags.contentblocks.contentblock_as_divs(slug, category=None)
Description:
Render a ContentBlock wrapped in a <div> tag. For container blocks, each of its children are wrapped in a div
Arugment(s):
  • ** slug ** (required) : the unique identifier for the block
  • ** category ** : taxonomy to organize blocks

Usage:

{% contentblock_as_divs 'landing-'|add:group 'content' 'public' %}
mirskutils.contentblocks.templatetags.contentblocks.contentblock(slug, field=None, category=None)
Description:
Access a ContentBlock directly without rendering its contents
Arugment(s):
  • ** slug ** (required) : the unique identifier for the block
  • ** field ** : if specified, attribute provided
  • ** category ** : taxonomy to organize blocks

Usage:

{% contentblock 'contact-us' 'content' 'public' as ctnt %}
{{ ctnt.text }}