Archive for May, 2008

Screen dump of the day

Thursday, May 22nd, 2008

Just for the nerd fun of it and for that I really like the look n feel of my desktop right now – here’s screen dump of my every day ubuntu environment..

TemplaVoila in your own extension

Thursday, May 15th, 2008

TemplaVoila is an incredibly smart tool for templating your TYPO3 website. However it cannot only be used for pages and fragments of pages (FCE:s), but also for templating your own extensions output.

The classic way of adding template support for an extension has been to use an HTML file marked with tags like

  1. ###MY_REPLACED_MARKER###

or similar that would be replaced by content using the cObj function substituteMarkerArrayCached:

  1. $markerArray[‘###MY_REPLACED_MARKER###’] = $data;
  2. $output =  $this->cObj->substituteMarkerArrayCached($template, $markerArray);

Which is a quite simple and easy to use approach. The TemplaVoila way quite similiar. Let me show you a short example more or less cut from the mininews extension with a few simplifications for us mere mortals;

First off we will load up TV with a hard coded TO (Template Object) record uid. I suggest using some kind of FlexForm setting or similar for that ;) This part normally goes into an init() function or so;

  1. // Load and initialize TemplaVoila TO (if any)
  2. if (t3lib_extMgm::isLoaded(‘templavoila’))    {
  3.   $field_templateObject = 1;  //read my default page "TO" record uid..
  4.   if (intval($field_templateObject))    {
  5.     $this->TMPLobj = t3lib_div::makeInstance(‘tx_templavoila_htmlmarkup’);
  6.     $this->TA = $this->TMPLobj->getTemplateArrayForTO(intval($field_templateObject));
  7.     if (is_array($this->TA))    {
  8.       $this->TMPLobj->setHeaderBodyParts($this->TMPLobj->tDat[‘MappingInfo_head’],$this->TMPLobj->tDat[‘MappingData_head_cached’]);
  9.     }
  10.   }
  11. }

What the code above does is checking if TV exists, instantiates the templavoila HTML markup utility class (tx_templavoila_htmlmarkup), loads a TO record with uid one into it and finally sets some HTML header taggings..

Sooo, we got ourself a loaded TO with HTML template contents and also since TO always has a DS, we got the data structure fields (like field_mainMenu or similar). Next of is adding contents to where we’d like to have it. In our case into the field field_content mapped with TV.

  1. //we got some content into $content var loaded from db earlier, now render it with TV
  2. if (is_array($this->TA))    {    // TemplaVoila:
  3.   // Create list of elements:
  4.   $templatedResult = $this->TMPLobj->mergeDataArrayToTemplateArray(
  5.     $this->TA,
  6.     array(
  7.       ‘field_content’ => $content
  8.     )
  9.   );
  10. }
  11. $out = $templatedResult;

That’s it! :)

Using TemplaVoila for an extension has many benifits, just as using it for normal page rendering. One of them is the possibility to easily map your template using Templavoila. I suggest that you supply a valid datastructure (DS) xml with your extension, that gets loaded as static ds (again taken from mininews);

  1. // Adding datastructure for Mininews:
  2. $GLOBALS[‘TBE_MODULES_EXT’][‘xMOD_tx_templavoila_cm1′][‘staticDataStructures’][]=array(
  3.   ‘title’ => ‘Mininews Template’,
  4.   ‘path’ => ‘EXT:’.$_EXTKEY.‘/template_datastructure.xml’,
  5.   ‘icon’ => ,
  6.   ‘scope’ => 0,
  7. );

For a more detailed documentation around TV and the source to inspiration for this article, see the TemplaVoila extension documentation (http://typo3.org/documentation/document-library/extension-manuals/templavoila/1.3.4/view/1/6/)

jEdit with typoscript syntax highlighting

Tuesday, May 13th, 2008

A short tip; If you’d like to have syntax highlight for your TypoScript code in jEdit on *.txt files (apart from *.ts),  then you would first install the TypoScript plugin, and then set (for instance) “First line glob” field under Global options to

//TSFILE

and type the same on the first line in you ts file. The next time you open it, it will highlight your code.  Simple and effective.

Upgraded wordpress

Tuesday, May 6th, 2008

It was time to do another of those way to late updates. This time my WordPress installation (powering this blogg) was my target. Techie Buzz supplies a really neat update plugin that makes it safe and easy. Check it out

Although the auto update plugin was easy as a breeze to use, it wouldn’t hurt of having some more user friendly error handling when it gets write permission errors and such. They are handled but you get the feeling of being a bit stranded. I had some file writing permission problems..  :-)

I’m normally doing most of my work with or within the TYPO3 environment, and I must say that the clean and “just working” style of WP is a desirable target for the TYPO3 backend (and others) tool. Really neat.

Fixing an eclipse crach

Tuesday, May 6th, 2008

Recently I wasn’t able to start up my Eclipse (vaugly remembering having an X-hangup – x-windows crach I mean). All I got was a small error dialog with a reference to eclipse log file containing huge traceback of java exceptions.. I didn’t have the time or energy to trace this so I swaped to jEdit for a while.

Sooner or later one has to deal with the problems. The later was today.. My method became deleting each plugin path under [workspace path]/.metadata/.plugins/

The solution was quite simple.. I removed the file .snap in the [workspace path]/.metadata/.plugins/org.eclipse.core.resources/ path and it started working again! :-)

I’m no expert in how Eclipse handles it’s workspace data, but apparently I lost associated projects.. ..but that’s that not so tuff to add again.