Base Template

The base template is the template that will contain the header and footer area of your theme pages, as well as some other global information and container wraps. All other templates are extensions of the base template.

One basic concept to understand about Django is blocks. If you declare a block of code in the base template - indicated by code inside {% block some-name %} code inside here {% endblock some-name %} it will automatically carry through to the other templates, assuming you place this code at the top of the page: {% extends "base.HTML" %}.

Tip: See Django's documentation for further reading on Django inheritance and template blocks

If you place a block on a template that inherits base.HTML, but leave the block empty or add code inside it that varies from what is on the base template, your new template will override the code from the base template for that particular block. In short, the sub-templates automatically inherit blocks of code from the base template unless they are explicitly overwritten.

On the flip side, you will see some examples of empty blocks inside the base template. A block must first be declared on the base template in order to be used on a sub-template. If you see an empty block on the base template, that may be because there is a corresponding block on a sub-template that actually does contain content. In other cases the block may not be in use at all, and could be removed from your theme.

Important content in the base template

  • {% if user.is_authenticated %} – checks if the user is logged in to Vidcaster. This is used to display the login bar, which is included as {% include "include/userstate.HTML" %}
  • block globalstatus – the code inside this block is for global errors and messages. You can use CSS to style it.
  • block endbodycontent – used on the custom page template to add scripts to the end of the body tag.
  • block headcontent – used on the custom page template to add scripts or CSS to the head tag.
  • twitter_screen_name and facebook_page_id – these account names can be set in the Vidcaster Add-ons settings, and will automatically populate.
  • current_site – your current site object. This has some attributes like name, description, domain, current_site.siteprofile.logo, current_site.siteprofile.favicon.url. You can use these for meta information.
  • /feeds/recent/ – the URI of the RSS feed for your site.
  • /custom.CSS – a stylesheet containing Django variables that control how the CSS affects the link color, text color, background color, and background image pickers within the Vidcaster Admin, Site > Design settings. Any CSS added to Custom CSS (also in Site > Design settings) is also appended to this file.
  • {% load page_extras %}, {% load item_extras %}, {% load sites_extras %} – these are files that contain custom functions. They can be loaded within any template page to enable the needed functionality.
  • media_path - this variable dynamically creates a path to the prebuilt theme's media folder (/media/themes/<theme-name>/). You do not have direct access the theme's media files, but rather you will be including your own media files (CSS, js, images) instead. One thing to note about this:


Next section →