Create Block


Blocks are the boxes of content that are displayed in Layout Regions (such as footer or sidebar) on your page. For more details, see CMS Blocks's documentation

For creating block, you need to follow some steps:

1. Create Location through seeds.

Create a json file of name theme_locations.json at VaahCms/Themes/BlogTheme/Database/Seeds/json/ this directory.

copy

├── BlogTheme ├── Database/ ├── Seeds/ ├── DatabaseTableSeeder.php ├── SampleDataTableSeeder.php ├── json/ ├── theme_locations.json

To run this seed, you have to add some code in DatabaseTableSeeder.php file.

copy

Now, you just need to reactivate the theme by visiting this url:

<project-url>/backend#/vaah/themes/

Once, the theme is activated, Location will also be created.

2. Create a Block.

To create Block, visit this url:

<project-url>/backend/cms#/blocks/

  • Enter the name
  • Select Theme
  • Select Location
  • Enter Sort in number, this will work when you call blocks by location name.
  • Enter content in Editor. You can edit in HTML Editor also.
  • Click on Save button.

Blocks will be fetch on frontend by two Codes:

By Block slug
{!! vh_block('logo') !!}
By Location name
{!! vh_location_blocks('top') !!}

You have to paste these codes in Web Pages.

Now, you can copy this code and paste it in home blade file. Remove hard code of logo.

copy

Now, You can see the Cms Block.