smartfaq
SmartFAQ is developed by The SmartFactory (http://www.smartfactory.ca), a division of InBox Solutions (http://www.inboxsolutions.net)

How do I make a custom block?
Requested by Carnuke and Answered by Mithrandir on 2004/10/30 17:03:24 (15458 reads)
Custom Blocks are created in Blocks Administration found in System Admin -> Blocks.

From here, it is possible to create blocks with one of four types:

HTML
Regular HTML code can be put in this block

PHP
Regular PHP code can be used in this block as if it was a block in a module. Note that you are in a function scope, when creating this block, so any global variables such as $xoopsUser (User object) and $xoopsDB (Database object) must be declared global before use

Autoformat (Smilies enabled)
Normal Xoops code format with linebreaks and XoopsCode tags such as [img ] and [url ] (without spaces)
Smilies are interpreted and converted to the corresponding image

Autoformat (Smilies disabled)
Similar to the other Autoformat, but smilies are not converted, but will be displayed as e.g. : -) (without spaces)

Please also see This flash tutorial for more details.


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

 More info needed

This seems more a description of the custom block area than an answer to the question, "How do I create a custom block?" Posting random text is one thing, but my question is: how do I make a useful block element. I am familiar with HTML and CSS, but don't have a clue about PHP. A practical illustration would be: how do I make a custom block that would display a single forum? Or how do I create a block that would display the title and a teaser of all of the articles in a single category.

 
  • Just can't stay away

 Re: More info needed

Look at the category of this faq - it is supposed to be explaning the administration interface, so this is an entirely appropriate amount of information.

If you are interested in creating custom blocks which use information from modules... your best option would be to look at the php code of the blocks that the module already supplies, adapt that to suit your needs and put your adapted code into a php custom block as outlined in this faq.

 
  • Just popping in

 and Javascript?

Can i put Javascript in the blocks? like paypal code or google adsense code, etc?

 
  • Home away from home

 Re: and Javascript?

Yes, you can put js directly in the blocks, but be careful how you call it if its remote.

If you are calling a remote .js file make sure you get the path rigt or give a full URL.

 
  • Just popping in

 Thanks!

Ahh, thanks for your help...
That certinley make things easier!

 
  • Quite a regular

 Creating blocks

I can't use javascript in Auto-Format neither HTML blocks. I have to use PHP Script instead. Is this right?

Thanks a lot.