Custom Block is a perfect solution for customizing your online store and attuning it to your needs. You may create custom blocks for anything you ever need and place wherever on your site.
Creating custom blocks is quite an easy procedure. Let's start with going to Administration > ViArt CMS > Custom Blocks. Your screen should look like the following:
There are a few predefined blocks which you can edit as well as a possibility to create your own. Click the 'New Custom Block' link to create a new custom block or 'Edit Block' to edit an existing. Now, we will take a closer look on how to create new blocks; however, screens in both cases would be very much the same.
Please press the 'New Custom Block' link. As you can see the 'Edit Block' screen consists of two parts: Administrative information and Appearance on page.
Administrative information
Here, you have to enter Block Name which system will use for identifying the block; that is it's a required field and it should be unique. There is also a possibility to add any comments for later usage.
Appearance on page
This section helps you to define how the block should look like on the website. As a rule, any block has title and its content. You can name your block by entering its title into the 'Block Title' field or leave it blank; in the latter case your block will be will not have any title.
As regards to block's content, ViArt Shop allows for two ways of providing your custom blocks with content. You can either point to a file which should be stored in your ViArt root folder and the system will use its content; or you can type the code straight into the 'Block Content' window. You can use a WYSIWYG HTML Editor or a Textarea editor (you can choose either of these at System > System Settings > Administrator HTML Editor).
In order to save the changes you made click the 'Save' button.
In order to leave without saving click 'Cancel'.
After the block is created, you will be able to place it to any page of your site through the Layouts section (Administration > ViArt CMS > Site Layout).
To insert PHP code in custom blocks
From version 3.2 you have the possibility to insert the PHP code in your custom blocks. You can add php-code to your custom block with php tags, and operate with contents using $block_body variable. This variable consists of all the html text you have in your block.
To activate PHP code functionality for custom blocks, please go to Administration > System > Global Settings and select where you want to insert your php code. Also, don't forget to switch from the 'WYSIWYG HTML Editor' to 'Textarea Editor' to view the code in your custom blocks correctly. Then open your custom block and insert your php code in the 'Block Content' textarea.
The basic code will look like this:
Feel free to add any text here <br> Something <?php echo "1"; ?>
⁄simple php code
or like this:
Feel free to add any text here <br> Something <?php $block_body = str_replace("Something", "Anything", $block_body); ?>
⁄php code with a variable replacement
One more example of php code:
<?php
$block_body .= "
<select>
<option>drop down<⁄option>
<⁄select>
";
?>
Save changes, add this block to the page you want via your CMS and check the site. The code you added to the block will look like:
Restrictions for custom blocks
When you add a custom block to any CMS page you can set certain restrictions for showing these custom blocks. When you choose a custom block from the list of available blocks, you will see a blue window in the right upper corner where you can set restrictions for displaying blocks for certain types of Users, Administrators.
As for the parameters, it is possible to use a special parameter 'category' for which you can specify categories ids delimited by commas. It should look like this, for example: category =1,2,3.
Each category has its unique number and to limit showing blocks for three categories with numbers 1, 2 and 3 you need to make your settings (restrictions) in the 'Parameters' field. It is essential to use id numbers instead of categories’ names as parameters can identify only numbers.
You can see a category id number when you mouseover the category link. In the status bar (bottom of the page) you will notice a link similar to the below one:
admin_category_edit.php?parent_category_id=0&category_id=45.
In this case the category number is ‘45’
|