Adding a Block

Author: Tammy

Source: https://efiction.org/community/info-tutorials/adding-a-block/

1. First you will need to go into the Admin area of your site and initialize the block if it hasn't been initialized already. Admin->Blocks and click "Initialize Block" for the block you wish to add.

2. On the same page, if the block has already been initialized, you will need to turn it on. The "Status" column of the table has 3 options: Inactive, Active, and Index Only. Inactive is turned off. Active will make it available for all pages. Index Only will make it available on the index page only. If you intend for the block to only appear on the index page set it that way as it will save resources on your site. (ETA: The only exception is the "Who's Online" block which should always be set to "Active" if you have it on.) Click "Submit" to save the changes.

3. If you're using a skin that you didn't create, check the variables.php to see if the block isn't turned off there. Again, if a block is turned off it saves resources for the site so some skins use variables.php to turn blocks off that aren't being used. Look for a line in the file like this:

$blocks['BLOCKNAME']['status'] = 0;

BLOCKNAME will be the name of the block. Delete this line if you find it. You may find other lines that start with:

$blocks['BLOCKNAME']....

These lines will be configuration settings for the block. You may or may not want to delete these lines as well. It is suggested that you leave them until you have the block displaying on the page then delete or edit them one at a time until you get the effect you want.

4. The final step in adding a block to your skin is adding it to the .tpl files. Generally, you will want to add it to either header.tpl, footer.tpl, or index.tpl depending on where (and when) you want it to appear. All of the default blocks can be added using the {BLOCK_title} and {BLOCK_content} variables. Many of the blocks also have more complicated options for adding them to your skins. These variables will generally be surrounded by html in your skin. Open the .tpl file where you want the block to appear then add the {BLOCK_title} and {BLOCK_content} variables to the HTML you find there. Example:


<div class="block">
   <div class="title">{BLOCK_title}</div>
   <div class="content">{BLOCK_content}</div>
</div>

Last updated