6.1.1: Blocks HOW-TO  my english can be not so perfect :-) Question: What is difference
between block and module?
Answer: Block
is what is present at the left/right side of DragonFly portal. You can see them
on every page. For example: Who is Where, Login, CPG Main Menu, banner adds. Module
is central part of DragonFly and placed in central part. One module always is
more "central" and is displayed on the first page. All other
modules are accessible through links on left or right rows of blocks.
Both, modules and blocks,
must be activated by admin in administrative area, to be visible on a site.
Question: How can I write my
own block?
Answer: Look at the teps
below to create block and make it active on your site.
1. Copy the example code below:
<?php
/**
* CPG Dragonfly CMS
* Copyright © 2004 - 2006 by CPG-Nuke Dev Team, dragonflycms.org
* Released under the GNU GPL version 2 or any later version
* $Id: block-Sample.php,v 1.4 2006/10/07 07:54:11 nanocaiordo Exp $
*/
// protect against direct access
if (!defined('CPG_NUKE')) { exit; }
// show the content of the block
$content = 'Place the content that you wish to appear in your new block right here';
$content .= 'Note we use a dot before the = sign for each following line of code.';
2. Edit your block file.
All what you need is to get what you are going to display in
block and put it into $content variable. Do not use echo command!!!
Content can generated from database or static - it is all up to you!
Example of Adsense (for Google) block:
<?php
if (!defined('CPG_NUKE')) { exit; }
$content = '
<script type="text/javascript">/*<![CDATA[*/
google_ad_client = "string";
google_ad_width = int;
google_ad_height = int;
google_ad_format = "string";
google_ad_channel ="string";
google_color_link = "string";
google_color_url = "string";
google_color_border = "string";
google_color_text = "string";
google_color_bg = "string";
/*]]>*/</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>';
?>
3. Save your file as, for example, block-adsense.php
and transfer it into blocks directory. Notice that all block files start form
"block-"prefix. Do not forget to check ownership and permissions. They
must be the same as for the rest of blocks.
4. Go to adminstration area and in "General"
section click on "Blocks" icon. Select "adsense" in
Filename, make it active, decide who is allowed to see it (all, members or admin
only) and choose left or right side to display.
It will be added into table where you can fix a position by
"Weight" arrows: move it to top or bottom of left (right) side of your
page.
That's all major steps! Details you can always find yourself in
another blocks or ask at the DragonFly's forum.
|