PHPackages                             asgardcms/block - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. asgardcms/block

ActiveAsgard-module[Utility &amp; Helpers](/categories/utility)

asgardcms/block
===============

A module to create small blocks of content to display anywhere on the site.

3.0.0(8y ago)126.0k18[1 issues](https://github.com/AsgardCms/Block/issues)MITPHPPHP &gt;=5.6.4

Since Jun 9Pushed 5y ago6 watchersCompare

[ Source](https://github.com/AsgardCms/Block)[ Packagist](https://packagist.org/packages/asgardcms/block)[ RSS](/packages/asgardcms-block/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (6)Versions (26)Used By (0)

Block Module
============

[](#block-module)

[![Latest Version](https://camo.githubusercontent.com/266ffe486fb2cbf713f2755a4d1fa9743de5bcf632967d115d89ecd0039e0925/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f617367617264636d732f626c6f636b2e7376673f7374796c653d666c61742d737175617265)](https://github.com/asgardcms/block/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Quality Sblock](https://camo.githubusercontent.com/bfde04da595cd46628f94e88a1b220e4b175ea99547a2d9a34e75ec1ad886b41/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f617367617264636d732f626c6f636b2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/asgardcms/block)[![SensioLabs Insight](https://camo.githubusercontent.com/a37734297c2db1119807a32478913994525b507e8883ef75e92b40e308ba6766/68747470733a2f2f696d672e736869656c64732e696f2f73656e73696f6c6162732f692f36353063366432382d653838382d346262632d613537622d6366363834643366653762662e737667)](https://insight.sensiolabs.com/projects/650c6d28-e888-4bbc-a57b-cf684d3fe7bf)[![CodeClimate](https://camo.githubusercontent.com/3b8aecfa2b72c126f6e5a72d6adfa333942de6a8d0490e2130ec382cf7885aac/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f6769746875622f417367617264436d732f426c6f636b2e737667)](https://codeclimate.com/github/AsgardCms/Block)[![Total Downloads](https://camo.githubusercontent.com/c2f1b4180089800abb0c33ab9b8a7507bfdb041f1df9f47878cb49c6d8aaafc4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f617367617264636d732f626c6f636b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/asgardcms/block)[![Slack](https://camo.githubusercontent.com/5379498bc3498bb41df326f2981e2cae90bd1ba46d635bb0c0faedcdc746278d/687474703a2f2f736c61636b2e617367617264636d732e636f6d2f62616467652e737667)](http://slack.asgardcms.com/)

BranchTravis-cimaster[![Build Status](https://camo.githubusercontent.com/a927a0be89a8dd61e6697cb8725453e4dd930c5b4bea77ff6745615b9d156ffd/68747470733a2f2f7472617669732d63692e6f72672f417367617264436d732f426c6f636b2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/AsgardCms/Block)2.0[![Build Status](https://camo.githubusercontent.com/1421d8144da70f7efeec81036164e04cc49f6a5c0658d3e2bc241bcfce2a415e/68747470733a2f2f7472617669732d63692e6f72672f417367617264436d732f426c6f636b2e7376673f6272616e63683d322e30)](https://travis-ci.org/AsgardCms/Block)Installation
------------

[](#installation)

### Download

[](#download)

You can install the Block module, with the following command which allows the module to be edited for your project.

```
php artisan asgard:download:module asgardcms/block --migrations
```

### Composer

[](#composer)

You can install the Block module with composer:

```
$ composer require asgardcms/block
```

Then run the following command to install the database tables:

```
$ php artisan module:migrate Block
```

### Permissions

[](#permissions)

In the backend GUI, go to Users &gt; Roles &gt; Admin. Then the permissions tab, and give the Admin role the permissions for the block module.

Documentation
-------------

[](#documentation)

This is a very simple module to create re-usable blocks of content. The blocks of content are created in the administration. You give it a name and a content.

After this, you'll be able to get the content of a block with the following code:

```
{!! Block::get('block-name') !!}
```

Each block also receives a shortcode that can be used instead of the code mentioned above. Shortcode looks like this `[[BLOCK(block-name)]]`.
This is very useful if you for example want to allow users to reuse and enter blocks into content of the WYSIWYG editor (page or blog article body)

If you want to use shortcodes in your app, you need to register `RenderBlock` middleware responsible for parsing the response and replacing the shortcodes with the actual block content. It can be done globally by editing `app/Http/Kernel.php` file and adding `\Modules\Block\Http\Middleware\RenderBlock::class`into the `$middlewareGroups` `web` group (this way, block shortcodes will be automatically replaced in all `web` routes on frontend):

```
