Home Page

Tips page

University Page

Programming

Debian & Linux

Some works

About me

Del.icio.us Bookmarks

BOINC Combined Statistics

Site Statistics

Contact me sending an e-mail (antispam defense activated)

debian

hacker emblem

blogger

GeoURL

View Sandro Tosi's profile on LinkedIn

This is my Google PageRank

Dragonfly CMS Development Tips

Dragonfly CMS Development Tips

 

While creating the new site from my swimming team (available here), we choose Dragonfly as our CMS (Contents Management System). After a phase of DragonFly exploration, fastly I realize I will need to create some new modules/blocks for our purpouse. In the main site and around the web I couldn't find any resource about extentions developement, so I'll try to put here everything I'll discover.

Follow, there will be a list of things, it won't be an organic paper, but a collection of tips.

 
  • I've start looking for infos with a post in Dragonfly forums; you can find some information there;
  • If you want to create a module called MyModule, create a directory under <dragonfly_dir>/modules/ with name MyModule; inside that directory, create a file called index.php: inside this file you can create the module as you please; if that module has to install something (for example some tables in the db), create under the same dir the file cpg_inst.php (follow the structure of other modules installation files). Once created the directory and the file(s), go to the Administration Page under General > Modules link and you'll find you new module, ready to be activated and installed (if needed).
  • if inside a module (maybe a block) yo need to call itself, for example to pass some parameters in the URL, do not call it explicitly, like echo "<a href='index.php?name=MyModule&param1=a&param2=b&...'>link</a>"; but use the function getlink(): the previous link will become echo "<a href='".getlink('MyModule')."&param1=a&param2=b&...>link</a>"; .
  • writing the code for a module/block, seems no need to close the <?php tag with a ?> at the end of the page;
  • use variable $pagetitle to set the title page for a module;
  • If you have to create a block, go under <dragonfly_dir>/blocks and create a file block-MyBlock.php (use underscore, _, in the file name to have a name with spaces: block-My_Block.php will create a block called "My Block"). Do not include header.php or footer.php and replace every echo with $content.= 
  • You're developing a new module, and when displaying it, you'd like to show even the left/right block, but they won't come up. Add this code to the module:

    ...

    // add $showblocks to global
    global ...,$showblocks,...;

    $showblocks=3;

    // include the header in the page generation
    require_once('header.php');

    ...

    Add $showblocks to global, than set its value to one of the following: 1 for left blocks, 2 for right blocks, 3 for both (more info about this is available inside includes/functions/display.php , in the function blocks_visible() ). If you not set that variable, your module will take all the page size...
    That was the hard way (and almost wrong); if you'd like to follow rules and use an easier one, do this (I suppose the module is already installed): go to admin section, Modules, click on "Edit" on the same line of your module; now choose in the drop-down-list for "Blocks" which one show: no-one, the ones on the left, on the right, or both.
    Please note that setting $showblocks in the page code has a higher priority then the one set in the modules admin page, i.e. set Blocks > Both in the admin page, but set $showblocks=1 , your page will only show left block. Moreover, you can show center or bottom blocks only through code inside the module.