| Home | Podcasts | 

External blocks with dynamic templates in #Chisimba
67 days ago

Chisimba can display blocks on another Chisimba server, using the dynamic blocks module with the blocks specified in ajax format in a content or personal template. To display blocks in response to an external request, the host server must have the externalblocks module installed (in modules, not in core). In addition, the ALLOW_EXTERNAL_BLOCKS property of the Blocks module must be set to 1 on the host server. If this is not set to 1, then the host will not supply external blocks even with the externalblocks module installed.

To be valid for display externally, blocks must have a property expose set to true. This is done by the developer at thet ime of development of the block, and would normally be done in the init() method of the block as follows:

    public function init()
    {
        $this->title = "Demonstration block";
        $this->expose = TRUE;
    }

External blocks are rendered by the dynamiccanvas module, so only module that use the dynamiccanvas for displaying content can display dynamic blocks, although a filter is in development to provide external blocks within content. The minimal JSON content to display an external block is as follows:

       

Loading...


All the other parameters of the dynamic blocks JSON are available to external blocks. For example,

       
The display method is not set.
{
            "display" : "externalblock",
            "server" : "http://localhost/ch/",
            "module" : "dynamiccanvas",
            "block" : "thirdtest",
        }


will display the thirdtest block from the dynamiccanvas module on http://localhost/ch. The following will display the same block without a title.

       
Loading...


The only difference between the JSON to display regular blocks and that to display external blocks is in the two lines
            "display" : "externalblock",
            "server" : "http://localhost/ch/",

instead of just

            "display" : "block",

for an internal block.



Tags for this post

         
Bookmark this post Trackback URL  No trackbacks were found for this post Comments 0 Attribution Share Alike

My blockview: personal templates in #Chisimba
66 days ago

There is a new module in Chisimba that I wrote at the airport on my way to Madrid. It is very simple, and it only exists to demonstrate the power of dynamic templates. However, it could be expanded to provide for a system of user created templates that allow users to create their own look and feel. The module is myblockview (My block view).

To use it, a user may create a templates directory on a Chisimba server using file manager. In that directory, then create a new directory, one for each template, and load into it a file called template.txt file containing a typical dynamic template of the same kind you would use in a module powered by dynamic templates.

Let's say you create a directory called templates, and then in it you create a directory called default. Then you would create a template contianing the three column divs that you would expect in Chisimba as follows.

 <div id="Canvas_Content_Body_Region1">
    Put some content here for the left column
    </div>
    <div id="Canvas_Content_Body_Region3">
        Put some content here for the right column
    </div>
    <div id="Canvas_Content_Body_Region2">
        Put some content here for the wider, middle column.
    </div>
</div>

Of course, this is not very powerful in itself, but if you combine this form of dynamic canvas with the dynamic blocks specified using JSON, then you can have your own design for a Chisimba interface very quickly.

This module is just a proof of concept to show the power of the dynamic canvas approach to templates. Took me <30 minutes to make it, sitting in the airport. Hopefully, this can stimulate some other ideas.  To use it, install the myblockview module and play around with creating your own templates as described above. At the time of writing, there is little or no error trapping or checking, so if you use it, be warned, it is developer grade code, not yet ready for unleashing on users.



Tags for this post

         
Bookmark this post Trackback URL  No trackbacks were found for this post Comments 1 Attribution Share Alike
Weblog of: Derek Keats
Login




Remember me

Forgot your password?
HELP

toggle Twitter
You cannot tweet unless you are logged in, and on your own page.
Follow me on Twitter Follow me on Twitter
Friend me on Facebook Add me on Facebook
Chisimba Facebook group Chisimba Facebook group





Afrigator