Personal tools
Namespaces
Variants
Actions

Design:Layout.html

From Katapulta

Jump to: navigation, search

Fișierul layout.html este un fișier HTML/XHTML care conține și tag-uri Twig.

Un exemplu de fișier de tip layout poate arăta astfel:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>{% block title %}My Shop{% endblock %}</title>

  <link rel="stylesheet" type="text/css" href="{{'mystyle.css'|asset_url}}" />
  <script type="text/javascript" src="{{'myscript.js'|asset_url}}"></script>
</head>

<body>

  <div id="header">
    {% block header %}
      <h1 class="logo"><a href="{{ shop.url }}" title="{{ shop.name }}">{{ shop.name }}</a></h1>  
    {% endblock %}
  </div>

  <div id="main-menu">
    {% block mainmenu %}
      <ul>
      {% for link in link_lists['main-menu'].links %}
        <li><a href="{{ link.url }}" {% if link.url == active_url %} class="current" {% endif %}>{{ link.title|e }}</a></li>
      {% endfor %}
      </ul>
    {% endblock %}
  </div>

  <div id="container">
    <div id="sidebar">
      {% block sidebar %}
        {% include 'widgets/cartsummary.html' %}
        {% include 'widgets/shopbyvendor.html' %}
        {% include 'widgets/shopbytype.html' %}
      {% endblock %}
    </div>
    
    <div id="content">
      {% block content %}
        <p>[...content here]</p>
      {% endblock %}
    </div>
  </div>

  <div id="footer">
    {% block footermenu %}
      <ul>
        <li><a href="{{ pages['about'].url }}">About Us</a></li>
        <li><a href="{{ pages['contact'].url }}">Contact Us</a></li>
        <li><a href="{{ pages['terms'].url }}">Terms and conditions</a></li>
      </ul>
    {% endblock %}
    
    {% block copyright %}
      <p>&copy; 2011. All Rights Reserved.</p>
    {% endblock %}  
  </div>

</body>
</html>

Aici vor fi definite blocurile de date (block) care vor fi suprascrise de celelalte template-uri (product, collection, post, etc).

De exemplu, unul din blocurile importante care trebuie să se regăsească în orice temă Katapulta este cel denumit în exemplul de mai sus content (numele nu este important) care va si suprascris în toate template-urile cu conținutul specific fiecărui template.

Notă:

Pot fi definite mai multe fișiere de tip Layout având nume diferite și care pot fi folosite individual în template-uri.

Variabile

În template-ul layout.html ai acces la toate variabilele globale.