| Home | Podcasts | 

Latest Post - Category: Chisimba development and use

How to return data for Ajax in Chisimba
3 days ago

In any Chisimba module, based on the MVC architectural paradigm, you will have a controller and templates, and of course you might have models and a variety of helper classes. Here, we are only concerned about the controller and templates.

The controller is in the root of the module, and is named controller.php. Templates may be of three kinds: content, layout, and page. In general, we do not need to touch page or layout templates, only the content templates.

Use case: You want to return some data for an Ajax call, so you can do something with it in Javascript and insert it into the page. You need to return only the required data without any of the user interface components or webpage components that Chisimba normally renders.

Lets say that you have a module called dosomething. You are calling for a user name through an Ajax call. The URL you are calling from within your Ajax code might be something like:

http://localhost/index.php?module=dosomething&action=getname

which you expect to return just the name, say Derek Keats.

Using the standard appoach, without suppressing all the user interface elements, you will get data that are unusable in Ajax. You need to suppress all that using a custom page template.

The Controller for your module would have a method __getname()
which would do something like:

public function __getname()
{
    $str = "Derek Keats";
    $this->setVarByRef("str", $name);
    $this->setPageTemplate('ajax_template.php');
    return "ajax_tpl.php";
}

Note that there are two templates used here, the custom page template, ajax_template.php and the content template ajax_tpl.php. Within your module, you must have a templates directory, and inside it you must have one called page, and one called content. That is,

dosomething/templates/page/ajax_template.php
dosomething/templates/content/ajax_tpl.php

The file ajax_template.php should contain only

<?php
echo $this->getLayoutContent();
?>

The file ajax_tpl.php should contain only


<?php
echo $str;
?>

That is it. Any data can be returned for use by Ajax calls in this way.



Tags for this post

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

Previous Posts

FLOSSInclude workshop concludes in Brussels
25 days ago

The FLOSSInclude project’s final workshop was recently held in Brussels (7th to 8th June 2010). All of the consortium members attended the workshop and gave a presentation on their pilots and case studies of FLOSS projects within their institution or region.

No caption provided

The FLOSSInclude project http://www.flossinclude.org/ is a European commission (EC) funded project and aimed to build on the corpus of FLOSS research that the EC had built up. The study also built on the highly successful FP5 FLOSSPols project http://www.flosspols.org/ and the FP6 FLOSSWORLD project http://www.flossworld.org/. The FLOSSInclude study was a more focused study than its predecessors and focused more on regional FLOSS initiatives and FLOSS needs within the target regions. The reports and data collected on the project will be used to be a European Commission roadmap on FLOSS research and possibly shape future FLOSS policy in Europe and elsewhere.

The major areas addressed by the FLOSSInclude study were the following:

  • Analysis of available data to identify key problem areas and areas of blocked potential for FLOSS in the target regions. Dissemination and networking, to identify and federate local and regional initiatives
  • Requirements analysis, to show with concrete cases the specific technical, business and socio-political needs for the growth of FLOSS use, deployment and development in target regions
  • Validation and pilots, to ensure that FLOSS solutions, tools and services can be cost-effective and practical
  • Prepare a cooperation roadmap, supported by regional initiatives, concrete cases for clearly identified requirements, with solution areas proposed that have been validated through pilots.

No caption provided


FLOSSInclude in Africa was represented by the University of the Western Cape (UWC) and the India Kofi Annan Centre of Excellence in ICT in Ghana. Both Nic Appleby and Enver Ravat gave presentations on the case study “e-learning and Kewl 3.0: the implementation of web 3.0 advanced technologies”). The case study explored e-learning at UWC and included a range of issues from e-learning structures to development problems of the world class, locally developed e-learning platform (Kewl 3.0) to the challenges faced by the e-learning team at implementing a sound e-learning policy at UWC and placing University of the Western Cape at the vanguard of e-learning innovation in South Africa. It also documented the use of e-learning outside of the University within the regional context. For more information on the case study and project please mail Enver Ravat (at eravat2@gmail.com).

No caption provided



Tags for this post

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

Chisimba vuvuzelas and learning in Polokwane
43 days ago






Participants-Keen-To-Learn, originally uploaded by Paul Mungai.


I bet this is the only software framework where programmers get a free Vuvuzela!



Tags for this post
This post has not been tagged

         
Bookmark this post Trackback URL  No trackbacks were found for this post Comments 0 Copyright PDF of this post email this post to a friend

Le Vuvuzela de #Chisimba
51 days ago






Le Vuvuzela, originally uploaded by wesleynitsckie.


The guys at UWC created a Chisimba vuvuzela to take to OSCON. If this doesn't get attention, nothing willl!



Tags for this post
This post has not been tagged

         
Bookmark this post Trackback URL  No trackbacks were found for this post Comments 0 Copyright PDF of this post email this post to a friend

Digital business card in #Chisimba
57 days ago

The digital business card module is incomplete, but works and provides a vcard compatible business card for Chisimba. This is for someone who is experimenting with it.

Currently, the fields are stored in user paramters (MENU: user | user configuration). The plan is to move this to triplestore as soon as triplestore has a user interface (no planned timeline, no list response to query). The following fields will generate the business card:

ABOUT ME:
tagline

SOCIAL NETWORKING:
africatorurl
deliciousurl
diggurl
facebookurl
flickrurl
friendfeedurl
googleurl
identicaurl
linkedinurl
mutiurl
operaurl
picasaurl
qikurl
slideshareurl
technoratiurl
twitterurl
youtubeurl

ADDRESSES:
addr_home
ddr_city_home
addr_city_work
addr_postalcode_home
addr_postalcode_work

MAP:
latitude
longitude

PHONE:
phone_home
phone_work
phone_cell

TAGS:

tags
   separated by a dash -
   e.g. geek-elearning-chisimba-php

WEBSITES:
homepage

Happy experimenting!



Tags for this post

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

mLearning with #Chisimba
57 days ago




Paul Scott shows the login screen for Chisimba's mLearning skin. The mLearning skin was developed for use of UWC's eLearning site on mobile phones.



Tags for this post
This post has not been tagged

         
Bookmark this post Trackback URL  No trackbacks were found for this post Comments 0 Copyright PDF of this post email this post to a friend

My blockview: personal templates in #Chisimba
60 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 0 Attribution Share Alike

External blocks with dynamic templates in #Chisimba
61 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

Block-based dynamic canvas for #Chisimba
64 days ago

Since I code for relaxation, for the past few days of my holiday I have been doing some work on Chisimba to improve the way in which it renders its look and feel, as well as the way in which it parses templates to render content. Everything I do is backward compatible.

Following on from the idea of dynamic canvases, I have made it possible for Chisimba to render an entire template based on functionality of Chisimba that we call blocks. There are two types of blocks in Chisimba, narrow blocks and wide blocks. Narrow blocks work on the side columns of 2 and 3 column layout, and wide blocks work on the middle area of 1, 2 and 3 column layout.

To use blocks to make a template, it may be necessary to use output buffering. To do this, add the following to the top of the template:

<?php
ob_start();
?>

Then add the following to the bottom of the template:

<?php
// Get the contents for the layout template
$pageContent = ob_get_contents();
ob_end_clean();
$this->setVar('pageContent', $pageContent);
?>

You then need a layout template in your module that contains:

<?php
$objBlocks = $this->getObject('blockfilter', 'dynamiccanvas');
$pageContent = $this->getVar('pageContent');
$pageContent = $objBlocks->parse($pageContent);
echo $pageContent;
?>

In your controller, for methods that will render the block-based dynamic canvas, you need to ensure that you enable the layout template using:

$this->setLayoutTemplate('demo_layout.php');

For this to work, you need a version 3.0+ skin, and you need to use the Chisimba Canvas layout, which is as follows:

<div id="Canvas_Content_Body_Region1"></div>
<div id="Canvas_Content_Body_Region3"></div>
<div id="Canvas_Content_Body_Region2"></div>

Note that Canvas_Content_Body_Region2 is the middle, but needs to be presented last in order for the columns to float and align correctly.

For 2-column layouts this would be:

<div id="Canvas_Content_Body_Region1"></div>
<div id="Canvas_Content_Body_Region2"></div>

Blocks are inserted using JSON syntax as follows:

 

The display method is not set.
The display method is not set.
{
    "display" : "block",
    "module" : "modulename",
    "block" : "blockname",
    "blocktype" : "blocktype",
    "titleLength" : "titlelength",
    "wrapStr" : 0|1,
    "showToggle" : 0|1,
    "hidden" : "value,
    "showTitle" : 0|1,
    "cssClass" : "cssClass",
    "cssId " : "cssId"
 }

Thus, adding the above block to the left column in such a template would consist of including it in the Canvas_Content_Body_Region1 div as follows:

<div id="Canvas_Content_Body_Region1">

 

The display method is not set.
The display method is not set.
{
    "display" : "block",
    "module" : "modulename",
    "block" : "blockname",
    "blocktype" : "blocktype",
    "titleLength" : "titlelength",
    "wrapStr" : 0|1,
    "showToggle" : 0|1,
    "hidden" : "value,
    "showTitle" : 0|1,
    "cssClass" : "cssClass",
    "cssId " : "cssId"
 }

</div>

Everything except display, module and block are optional. A template made up in this way might look like:

<?php
ob_start();
$objFix = $this->getObject('cssfixlength', 'htmlelements');
$objFix->fixThree();
?>

<div id="threecolumn">
    <div id="Canvas_Content_Body_Region1">
       

toggle Test 1
The first test is successful

       
    </div>
    <div id="Canvas_Content_Body_Region3">
       
toggle Test 2
The second test is successful. This bloc should have a little more text.

       
toggle Login




Remember me

Forgot your password?
HELP

       
Type: wrapper
This is an example of a block rendered using type wrapper. It places the title in a dark outside layer, and the block output in a light inside layer.

       
Type: table
This is an example of a block rendered using type table. It places the title in a normal header cell, and the block output in a table cell.

       
    </div>
    <div id="Canvas_Content_Body_Region2">
       
toggle My Profile
User Image

 

  Email address:
  Mobile number:
  Country: unknown unknown
  Gender: Unknown

Update Your Profile


       
The block is not valid.
{
            "display" : "block",
            "module" : "dynamiccanvas",
            "block" : "nonexistentblock"
        }

       
Loading...

       
Loading...

    </div>
</div>

<?php
// Get the contents for the layout template
$pageContent = ob_get_contents();
ob_end_clean();
$this->setVar('pageContent', $pageContent);
?>

Note that the lines

$objFix = $this->getObject('cssfixlength', 'htmlelements');
$objFix->fixThree();

are there to equalize the columns. This need will shortly be removed.

For a working example of this, see the dynamiccanvas module. 



Tags for this post

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

Mowing the pitch at Soccer City
67 days ago

I am trying to post a photo every day, in lieu of anything else interesting right now. Today I chose this photo from lat night. ISO 1600 makes it a bit grainy, but the point here is the subject and action, not the photo.

Worker mowing the grass at Soccer City in Johannesburg, just before the Argentina-Mexico game. When we got to a big game at a facility such as this, during the world cup, we often forget that the boys who kick the ball are not the only professionals that make it possible. There a lot of people with a lot of different skills involved it creating the 'beautiful game'.

This is true of the work that all of us do. As a DVC at a top university, I could not do my job, and achieve anything without the support of many bright, talented, dedicated people. So, instead of showing the Argentinian goal, I thought I would share a photo of this gentleman, in appreciation of all who make great things possible through their dedication behind the scenes.



Tags for this post
This post has not been tagged

         
Bookmark this post Trackback URL  No trackbacks were found for this post Comments 0 Attribution Share Alike PDF of this post email this post to a friend
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