public
Description: The ultra-lightweight ultra-flexible blogging engine with a fetish for birds and misspellings.
Home | Edit | New

Building default.twig

Lets start building the layout of your new website.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head profile="http://gmpg.org/xfn/11">
    <meta http-equiv="Content-type" content="$theme.type; charset=utf-8" />
    <title>{% block title %}$site.name{% if title %} &raquo; ${ title | escape }{% endif %}{% endblock %}</title>
    <meta name="generator" content="Chyrp" />
    <link rel="pingback" href="$site.chyrp_url/includes/xmlrpc.php" />
    <link rel="EditURI" type="application/rsd+xml" href="$site.chyrp_url/includes/rsd.php" />
    $theme.feeds
    $theme.stylesheets
    $theme.javascripts
${ trigger.call("head") }

So as you can see we start with the default code you need when building a webpage

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head profile="http://gmpg.org/xfn/11">
    <meta http-equiv="Content-type" content="$theme.type; charset=utf-8" />
    <title>{% block title %}$site.name{% if title %} &raquo; ${ title | escape }{% endif %}{% endblock %}</title>
    <meta name="generator" content="Chyrp" />
    <link rel="pingback" href="$site.chyrp_url/includes/xmlrpc.php" />
    <link rel="EditURI" type="application/rsd+xml" href="$site.chyrp_url/includes/rsd.php" />

In the page title we want to display the site name

<title>{% block title %}$site.name{% endblock %}</title>

But, because browsing the internet is dynamic we want to show where you are at the moment. To do that we add the title of the current page.

<title>{% block title %}$site.name{% if title %} &raquo; ${ title | escape }{% endif %}{% endblock %}</title>

Enough talking about the head. Time to give your website some body
<body>
  {% if visitor.group.can("add_post", "add_draft", "add_page", "view_own_draft", "view_draft", "change_settings", "toggle_extensions") %}
  <div id="controls" {% if hide_admin %} style="display: none"{% endif %}>
    <ul>
    {% if visitor.group.can("add_post") %}
      <li><a id="add_post" href="{% admin "write_post" %}">${ "Write" | translate }</a></li>
    {% elseif visitor.group.can("add_draft") %}
      <li><a id="add_draft" href="{% admin "write_post" %}">${ "Write Draft" | translate }</a></li>
    {% endif %}
    {% if visitor.group.can("add_page") %}
      <li><a id="add_page" href="{% admin "write_page" %}">${ "Add Page" | translate }</a></li>
    {% endif %}
    {% if visitor.group.can("view_own_draft", "view_draft") %}
      <li><a id="your_drafts" href="{% url "drafts" %}">${ "Your Drafts" | translate }</a></li>
    {% endif %}
    {% if visitor.group.can("change_settings", "toggle_extensions") %}
      <li><a id="site_settings" href="$site.chyrp_url/admin/">${ "Admin" | translate }</a></li>
    {% endif %}
      <li class="close"><a class="toggle_admin" href="{% url "toggle_admin" %}">${ "Close" | translate }</a></li>

What you just did? You’ve started the body of your page and added the adminbar to the top of the page.

Last edited by evertsemeijn, Wed Dec 03 02:16:38 -0800 2008
Home | Edit | New
Versions: