Sunday, July 25, 2010

How to create an extension for Contao starting from a Language Pack

This tutorial is tailored for windows users, I’m sure that users of other operating system know how to adapt it to their needs :)

A few days ago I’ve released a command line script that aims to build a Contao extension starting from a language pack.

The project page is located at http://bitbucket.org/zedseries/contao_languagepack_builder/, the script can be downloaded from http://bitbucket.org/zedseries/contao_languagepack_builder/get/v1.0.1.stable.zip

Requirements

  • Php executable installed on your system (The script is written in php, so you must have a php cli installation to run it)
    If you do not have a php executable installed on your system, you can download a copy for windows at http://www.php.net/get/php-5.2.14-Win32.zip/from/a/mirror)
  • Some basic knowledge of the command line
  • An account on Contao.org (if you are a translator you can use your translator username)

Monday, July 19, 2010

Let users find custom templates with Contao 2.9

This article has developers as audience, if you came here wondering why your custom template doesn’t get listed, please contact the author of the extension and tell him about this article :)

From version 2.9 Contao introduces the concept to pick templates from different directories and subdirectories.

Contao 2.9 introduces also the concept of themes, and let users assign a directory of templates to a theme. You can read the full announcement here.

If an user put a custom template into a subdirectory of the main templates dir, some extensions will not show it.

Every developers should update their extensions to reflect the above changes, here I will propose a cross-version solution to solve this problem.

If your extension uses a custom template, you will have a line like this in your d.c.a (let me tell we are talking about the tl_example dca):

$GLOBALS[‘TL_DCA’][‘tl_example’][‘fields’][‘my_template_field’] = array(
‘inputType’
=> ‘select’,
‘options’
=> $this->getTemplateGroup(‘my_prefix’)
);






in order to list the templates that exists in the template folder assigned to a theme, you must make the following changes:




Create a class wherever you want




(the “Contao way”  of doing it is to create a class named as the dca inside the same file.)




 


class tl_example extends Backend {
public function __construct() {
parent
::__construct();
}

public function listTemplates($dc) {
if (version_compare(VERSION.BUILD, '2.9.0', '>=')) {
return $this->getTemplateGroup(‘my_prefix’, $dc->activeRecord->pid);
}
else {
return $this->getTemplateGroup(‘my_prefix’);
}
}
}





 




then change the field’s entry in your dca to take the list of templates from the above function:




 


$GLOBALS[‘TL_DCA’][‘tl_example’][‘fields’][‘my_template_field’] = array(
‘inputType’
=> ‘select’,
‘options_callback’
=> array('tl_example', 'listTemplates')
);





These changes will make you extension compatible with Contao 2.9 and mantain the compatibilty with older versions.




Please comment below if you find errors or you simply  want to say something :)

Sunday, July 11, 2010

Just published api.zedseries.com

I have just uploaded the documentation for ZedSeries Library to http://api.zedseries.com.

Feel free to comment below if you find errors or if you have suggestions to improve it.

Monday, July 5, 2010

ZedSeries Listing Tutorial (part #1)

Today was released ZedSeries Listing 1.6.0.stable, it is compatible with Contao 2.9 and is shipped with an inline guide. The following tutorial is taken from the inline guide. The project page is located at http://www.zedseries.com/zedseries-listing-extension-for-typolight.html. The issues are managed through bitbucket at http://bitbucket.org/zedseries/zedseries_listing/issues/. You can also visit the project page of ZedSeries Listing on Contao.org website.