Mecha CMS

Mecha CMS blog and documentation.

Please Don’t Edit the Chunk Files

Updated: Sunday, 07 August 2016

They are already standardized.

Table of Content

Please don’t edit the chunk files directly to update the HTML markup of your shield parts to match them with your own shield design. They are already standardized and may be changed on every CMS update. To create a custom shield parts, you can just create a duplicate files from the original chunk files stored in lot\extends\chunk and save it to the current shield folder. Example:

normal/
├── article.php
├── article.header.php ← [1]
├── …
└── …
  1. This will overrides the article.header.php markup from lot\extends\chunk folder.

Alternativelly, you can use the available hooks and filters supplied by the Shield::chunk() method:

Inserting

Example of adding an icon before the comments header text:

Filter::add('shield:chunk', function($content, $path) {
    if(File::N($path) === 'comments.header') {
        return str_replace('<h3>', '<h3><i class="fa fa-comments"></i> ', $content);
    }
    return $content;
});

Wrapping

Example of adding a wrapper to the chunk block:

Filter::add('shield:chunk', function($content, $path) {
    if(File::N($path) === 'article.body') {
        return '<div class="test-wrapper">' . $content . '</div>';
    }
    return $content;
});
Donation and Email Subscription