2.5. Blocks

Blocks are discreet sections of content that can be created and configured in the admin interface. Custom blocks can be created and are typically made up of text, graphics and pictures. The content in these blocks may be formatted individually or inherit the site formatting. Blocks may also be part of a modules display output. The blocks administration page is where all blocks are configured and administered.

2.5.1. Overview

The Blocks Administration page allows the Site administrator to organize the blocks for every page in the site. This page is divided in two sections. The first section displays the blocks configured in the system, filtered by three drop-down menu options at the top of the table. The second section is for the creation of a new block. As we have said, any installed modules are also displayed in this page; they will be discussed later in the guide.

First, to set properties of a block, it has to be displayed in the table of the Blocks Administration page. The following image represents the filters one can use to display the blocks information:

Blocks Administration

Figure 2.5. Blocks Administration

The three drop-down combo boxes select options for Show blocks visible in and Group and Visible. These options (together with the options set on each page) control much of the content and functions of the site, so it’s really worth getting familiar with this section.

Let’s look at fig.1. By default, the table will display the blocks that are defined to appear in the Top Page, for the “Registered Users”. Let’s have a look at some of the terms here.

  • Show blocks visible in” - This combo box sets the page where blocks are displayed. For example, the Top Page is the home page of the site. When a user types http://www.yoursite.com, the top page is what he sees. (This page can be set in the General Settings of the site). The other choices of this combo box will list the different modules of the site (Downloads, Web Links, Forum, etc…).

  • Group” - This combo box lists all the groups of the site. If the group “Webmaster” is selected, the table will display all the blocks for which the Webmaster group has access. Please note that the blocks permissions are defined in the Groups section and discussed later in this guide.

  • Visible” - The purpose of this combo box is simply to help the site administrator by filtering a specific visible status. This combo box has 3 items: “Yes”, “No” and “All”. The table will display the blocks that have their visible property set to that value. If “All” is selected, the table will return every block.

2.5.2. Configuring the blocks

Let’s have a look at the columns of the blocks table below these three menus.

ColumnDescription
Block DescriptionGives a short description of what the block displays.
TitleThe actual title of the block. This is the title that will be displayed by the block on the pages where the block is visible.
ModuleThe module that produces the block, i.e.; that puts the information in the block.
Side Left-Center-Right The position of the block. One of the 5 ‘option’ buttons must be selected for each block. For an easier explanation, we will give a number to each option, as represented on the image below:

  • Option 1 will display the block at the left end of the page.

  • Options 2, 3 and 4 represent the central section of the page. If option 3 is selected, the block will be display across the complete width of the central section.

  • However, if option 2 or 4 is selected, the block will be display across the center left or at the center right. Selecting option 2 or 4 will result in a smaller block then selecting option 3, but it will allow two blocks to be displayed side by side in the central section.

  • Finally, selecting option 5 will display a block at the right end of the page.

If no blocks are displayed in the right section of the page, the central section will start at the end of the left section and will expand to the end of the page. However, if no block is displayed in the left section, it will not affect the width of the central section and the left section will just be blank. It is, of course, not recommended to leave the left section with no block.

Also, the blocks that are defined with option 3 will always be displayed before the blocks that are defined with options 2 and 4.

Weight The weight is the value used by XOOPS to sort the display order of blocks in a page. The sorting is done by section. This means that the weight of a block in the left section will not affect the order of a block in the right section. The normal page is divided into four sections;
  • The top panel, or banner.

  • The left hand section, or main navigation bar.

  • The centre panel, or main page content.

  • The right panel, or second navigation bar.

The general principle is the following: the higher the number, the lower the block will be. It is indeed exactly like weight in real life: heavier things go down faster. It is useful to input your block weight in 5 or 10 increments. This allows for inserting items later without needing to change other weights.

Visible For a block to be displayed, it has to have its visible property set to ‘Yes’.
ActionThis column will be blank if the block cannot be modified. If it can, the word ‘Edit’ will appear, on which one could click to edit certain parameters of the block. If the block is a Custom block, the Action column will also have the word ‘Delete’ to permanently delete the block.

Table 2.4. Block Administration

2.5.3. Editing a block

When the “Edit” option is available, the Site administrator can click on the ‘Edit’ link in the action column of a block. This will display the detail properties of the block and allow editing of some of these. Here are the properties and their descriptions:

FieldDescription
NameThis is the name of the block. It cannot be modified here.
Block TypeThis is the position of the block, as defined in the ‘Side Left-Center-Right’ row of the Table 2. It may be set here also.
Weight This is the weight property of the block, as defined in the ‘Weight’ row of the Table 2. It may be set here also.
Visible This is the visible property of the block, as defined in the ‘Visible row of the Table 2. It may be set here also.
Visible in This property sets the pages where the block will be displayed. In addition to all the modules, the combo box items have ‘Top Page’ and ‘All Pages’. The ‘Top Page’ will display the block only in the top page; the ‘All Pages’ will display the block in every page of the site. Selecting multiple, non-consecutive pages is possible by holding “Ctrl” on keyboard.
Title This is the title that will be displayed in the webpage for the block.
Content The ‘Edit Template’ link will allow the Site administrator to edit the template of the block. Some HTML and/or PHP knowledge are required to do this.
OptionsMany blocks have options that can be set to fully customize the block. As the options are different for each block, we will not detail each one of them here.
Cache lifetime Cache lifetime is a useful feature for making a site run faster. If a block has fixed content that is unlikely to change on a regular basis, it is possible to instruct the browser to call the content from cache, rather than from the server. This is particularly effective if graphics are part of the content. Use the settings here to determine how long this content should be held in cache before returning to server fed data.

Table 2.5. Block Editing

2.5.4. Adding custom blocks

As we said before, the Blocks Administration page allows the Site administrator to add custom blocks. This is done by filling the fields of the Add a new block section. The properties are the same as the Table 2.5, “Block Editing”. Only one new property has to be set: Content Type, which defines the type of content that is entered in the Content area: HTML, PHP, etc..