SmartFAQ is developed by The SmartFactory (, a division of InBox Solutions (

How can I clone a block?
Cloning a block is so easy that a monkey could do it. The following example focuses on cloning the ‘recent news’ block of the News module, although the procedure should be the same for every block.

1. Open the file xoops_version.php in the module for which you want to clone a block. The path is: /modules/news/xoops_version.php

This file contains the declarations for creating all the blocks in the module. To clone the Recent News block, look through the code (under the // Blocks comment) until you find its declaration, which looks like this:

$modversion['blocks'][4]['file'] = "news_top.php";
$modversion['blocks'][4]['name'] = _MI_NEWS_BNAME5;
$modversion['blocks'][4]['description'] = "Shows recent articles";
$modversion['blocks'][4]['show_func'] = "b_news_top_show";
$modversion['blocks'][4]['edit_func'] = "b_news_top_edit";
$modversion['blocks'][4]['options'] = "published|10|25|0|0|0|0||1||||||";
$modversion['blocks'][4]['template'] = 'news_block_top.html'; // news_block_recent.html

As you can see, each block is assigned a unique number in its declaration. The Recent News block is number 4 out of a total of 7 in the version of this module that was current at the time of writing (1.44). We are going to make a copy of this block, which will become number 8.

2. To clone the block, copy the above code, and paste it in at the end of the other block declarations, changing the module number to 8. The pasted code should look like this:

$modversion['blocks'][8]['file'] = "news_top.php";
$modversion['blocks'][8]['name'] = _MI_NEWS_BNAME5;
$modversion['blocks'][8]['description'] = "Shows recent articles";
$modversion['blocks'][8]['show_func'] = "b_news_top_show";
$modversion['blocks'][8]['edit_func'] = "b_news_top_edit";
$modversion['blocks'][8]['options'] = "published|10|25|0|0|0|0||1||||||";
$modversion['blocks'][8]['template'] = 'news_block_top.html'; // news_block_recent.html

If you wanted to, you could also change the ‘description’ to something else, like ‘Shows football news’, or whatever.

3. To give your new block a unique name (optional as you can give it whatever user side name you like in blocks administration), open the relevant language file, which is something like: /modules/news/language/english/modinfo.php.

Look through the modinfo.php code until you find the block name definitions, which in this case are:

// Names of blocks for this module

define('_MI_NEWS_BNAME1','News Topics');
define('_MI_NEWS_BNAME3','Big Story');
define('_MI_NEWS_BNAME4','Top News');
define('_MI_NEWS_BNAME5','Recent News');
define('_MI_NEWS_BNAME6','Moderate News');
define('_MI_NEWS_BNAME7','Navigate thru topics');

Add another definition for your new block, using a unique number, eg:

define('_MI_NEWS_BNAME9','Yet another news block');

(The reason I used the number ‘9’ was that one of the blocks in xoops_version.php already uses 8, even though there is no corresponding entry in the language file. I don’t know why – but anyway, the important thing is to use a unique number).

4. Save and upload your amended xoops_version.php file.

5. Update the module for the new block to become available. Go to Administration => System module => Modules and press the ‘Update’ button for the News module. This will recompile the templates. You should see your new block listed as created in the results screen.

6. The new block should now be available in Administration => System => Blocks. You can do with it as you wish, just like any other block.

Other stuff.

7. To create a custom template for your block (if you want to), you could create a custom template for your new block. If we go back to the last line of our cloned Recent News block declaration:

$modversion['blocks'][8]['template'] = 'news_block_top.html'; // news_block_recent.html

The procedure would be to i) make a copy of the relevant template, in this case news_block_top.html with a new name such as ‘news_block_football.html’, ii) make whatever changes are necessary, and iii) amend the code, in this example, to read:

$modversion['blocks'][8]['template'] = 'news_block_football.html'; // news_block_football.html

If you don’t create a separate template for the new block (and you don’t have to), then any changes you make to the template for the original block will also affect the clone.

Cool applications of cloning blocks.

1. Allows you to position a block in different locations in different modules.

2. Some blocks, like Recent News (or Recent Posts in the Forum modules) allow you to filter their content by category (this functionality is available via the ‘edit block’ links in blocks administration). So you could conceivably create a ‘recent news’ block for every category that you have. If you combine this feature with a duplicatable content module like TinyD, you can effectively create topic-specific sub-portals within your website – without doing any major or risky hacks!

The comments are owned by the author. We aren't responsible for their content.

 block cloning

thank you for this faq...saves me a lot of time



Users who use altsys, should udate altsys module too, and then modify the new block from altsys module admin menu.


 Pass me a banana!

Well cloning blocks might be so easy that "a monkey could do it", but I have failed somehow.

I have tried to clone the spotlight block in the AMS module, and this worked until I tried to change the template - now I get an empty block when I display it. Any ideas where I might have gone wrong? There are different templates for left, centre, right - could this be something to do with it? ANy help much appreciated.




does it work?



Who's Online

62 user(s) are online (1 user(s) are browsing XOOPS FAQ)

Members: 0

Guests: 62



Goal: $100.00
Due Date: Feb 28
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Did you know ?

you can use 'cronjob' in CPanel to complete backups of your database.

Random question

Why am I getting "Unable to install ???Error(s): Unable to write to main menu."?