Mecha CMS

Mecha CMS blog and documentation.

Shield

Updated: Sunday, 07 August 2016

“Shield” is a term used by Mecha to express “theme” in another CMS.

A shield is packaged in a folder with a unique name, and it is located in lot\shields folder:

ROOT
 └── lot/
      └── shields/
           ├── normal/
           ├── shield-2/
           ├── shield-3/
           ├── json.php
           ├── rss.php
           ├── sitemap.php
           ├── widgets.css
           └── widgets.js

A standard shield should at least contains files that structured like this:

shield-2/
 ├── assets/
 │    ├── object/
 │    │    └── images and other media goes here…
 │    ├── shell/
 │    │    ├── atom.css
 │    │    ├── layout.css
 │    │    └── manager.css
 │    └── sword/
 │         └── javascripts goes here…
 ├── 404.php
 ├── index.php
 ├── article.php
 ├── page.php
 ├── page-home.php
 ├── manager.php
 ├── comments.php
 ├── header.php
 ├── navigation.php
 ├── footer.php
 ├── sidebar.php
 ├── functions.php
 └── about.txt

atom.css, layout.css and manager.css

atom.css
Used to handle the miscellaneous elements appearance in page such as paragraphs, blockquotes, lists and buttons.
layout.css
Used to handle the shield layout and color appearance such as header, navigation, sidebar, widget, post, comment and footer.
manager.css
Used to handle the shield layout that will available only when user is logged in such as tabs, text editor icons and menu manager.

404.php

Minimum requirements for 404.php:

<?php include 'header.php'; ?>
<div>404 not found!</div>
<?php include 'footer.php'; ?>

index.php

Minimum requirements for index.php:

<?php include 'header.php'; ?>
<?php include 'sidebar.php'; ?>
<?php if($config->total_articles > 0): ?>
  <?php foreach($articles as $article): ?>
    <h4>
      <a href="<?php echo $article->url; ?>"><?php echo $article->title; ?></a>
    </h4>
    <div><?php Weapon::fire('article_footer', array($article)); ?></div>
  <?php endforeach; ?>
<?php else: ?>
  <p>No posts yet.</p>
<?php endif; ?>
<?php echo $pager->prev->anchor; ?> | <?php echo $pager->next->anchor; ?>
<?php include 'footer.php'; ?>

article.php

Minimum requirements for article.php:

<?php include 'header.php'; ?>
<?php include 'sidebar.php'; ?>
<h2><?php echo $article->title; ?></h2>
<div><?php echo $article->content; ?></div>
<div><?php Weapon::fire('article_footer', array($article)); ?></div>
<?php if($config->comments->allow) include 'comments.php'; ?>
<?php include 'footer.php'; ?>

page.php

Minimum requirements for page.php:

<?php include 'header.php'; ?>
<?php include 'sidebar.php'; ?>
<h2><?php echo $page->title; ?></h2>
<div><?php echo $page->content; ?></div>
<div><?php Weapon::fire('page_footer', array($page)); ?></div>
<?php include 'footer.php'; ?>

page-home.php

Minimum requirements for page-home.php:

<?php include 'header.php'; ?>
<div>Welcome!</div>
<?php include 'footer.php'; ?>

manager.php

Minimum requirements for manager.php:

<?php include 'header.php'; ?>
<?php include 'sidebar.php'; ?>
<h2><?php echo $page->title; ?></h2>
<div><?php if($page = Shield::lot('page')) echo $page->content; ?></div>
<?php include 'footer.php'; ?>

comments.php

Minimum requirements for comments.php:

<h4><?php echo $article->total_comments_text; ?></h4>
<?php if($article->total_comments > 0): ?>
  <?php foreach($article->comments as $comment): ?>
    <section id="comment-<?php echo $comment->id; ?>">
      <div>
        <?php if($comment->url !== '#'): ?>
          <a href="<?php echo $comment->url; ?>" rel="nofollow" target="_blank"><?php echo $comment->name; ?></a>
        <?php else: ?>
          <span><?php echo $comment->name; ?></span>
        <?php endif; ?>
      </div>
      <div><?php echo $comment->message; ?></div>
      <?php Weapon::fire('comment_footer', array($comment, $article)); ?>
    </section>
  <?php endforeach; ?>
<?php endif; ?>
<form class="comment-form" id="comment-form" action="<?php echo $article->url; ?>" method="post">
  <?php echo $messages; ?>
  <input name="token" type="hidden" value="<?php echo $token; ?>">
  <input name="parent" type="hidden">
  <p>Name:</p>
  <p><input name="name" type="text"></p>
  <p>Email:</p>
  <p><input name="email" type="email"></p>
  <p>Message:</p>
  <p><textarea name="message"></textarea></p>
  <p><?php echo Guardian::math(); ?> =</p>
  <p><input name="math" type="text"></p>
  <p><button type="submit">Publish</button></p>
</form>

header.php

Minimum requirements for header.php:

<!DOCTYPE html>
<html>
  <head>
    <?php Weapon::fire('SHIPMENT_REGION_TOP'); ?>
    <?php Weapon::fire('shell_before'); ?>
    <?php echo Asset::stylesheet(array(
        'assets/shell/atom.css',
        'assets/shell/layout.css'
    )); ?>
    <?php Weapon::fire('shell_after'); ?>
  </head>
  <body>
    <?php Weapon::fire('cargo_before'); ?>
    <header>
      <h1><?php echo $config->title; ?></h1>
      <p><?php echo $config->slogan; ?></p>
    </header>
    <?php include 'navigation.php'; ?>

navigation.php

Minimum requirements for navigation.php:

<nav>
  <?php echo Menu::navigation(); ?>
</nav>

footer.php

Minimum requirements for footer.php:

    <footer>&copy; 2014</footer>
    <?php Weapon::fire('cargo_after'); ?>
    <?php Weapon::fire('sword_before'); ?>
    <?php echo Asset::javascript('assets/sword/layout.js'); ?>
    <?php Weapon::fire('sword_after'); ?>
    <?php Weapon::fire('SHIPMENT_REGION_BOTTOM'); ?>
  </body>
</html>

sidebar.php

Minimum requirements for sidebar.php:

<aside>
  <?php if($manager && Widget::exist('manager')): ?>
  <?php echo Widget::manager(); ?>
  <?php endif; ?>
</aside>

about.txt

Minimum requirements for about.txt:

Title: The Shield Name
Author: Your Name
URL: http://example.org
Version: 1.0.0

====

> Description about this shield.

The usage, the external credits, etc.
Donation and Email Subscription