Posted: July 25th, 2010 | Author: tolleiv | Tags: extension, sprite, typo3 | No Comments »
TYPO3 4.4 ships with a long list of improvements. One of them is the sprite API which was developed during T3UXW09. It extends the iconWorks API and enables to retrieve any backend-icon from a central sprite.
As extension maintainer there are several ways to use these new parts of the API you can either just use it to display core icons, you can include your own icons and retrieve it with the new API or you can include your own sprite and retrieve the separate icons.
Use sprite icons
Using sprite icons is pretty easy, to get a checkmark icon you could use this:
t3lib_iconWorks::getSpriteIcon('status-dialog-ok');
The list of all available icons can be retrieved using the ‘spriteiconoverview‘ extension which I just recently pushed into the TER
Add your own icons
The API also provides the possibility to include your extension’s icons using either single icons or your own icon sprite.
Using single icons can be done with the following code in your ext_tables.php or ext_localconf.php:
$icons = array(
'myicon' => t3lib_extMgm::extRelPath('myextension') . 'myicon.gif'
);
t3lib_SpriteManager::addSingleIcons($icons, 'myextension');
Using this icon is easy again:
t3lib_iconWorks::getSpriteIcon('extensions-myextension-myicon');
If your extension comes with a larger amount of icons you might want to use your own sprite. This includes your sprite as a image file and a CSS file. The css file should look like this:
.t3-icon-extensions-myextension {
background-image:url(../../typo3conf/ext/myextension/myextension_sprite.gif);
}
.t3-icon-extensions-myextension-icon1 { background-position: 0px 0px; }
.t3-icon-extensions-myextension-icon2 { background-position: 0px -16px; }
The path to your sprite needs to be relative to the typo3temp/sprites/ folder, from where the (temporary) merged CSS file will be included.
This sprite can be included using:
$icons = array(
'extensions-myextension-icon1',
'extensions-myextension-icon2'
);
t3lib_SpriteManager::addIconSprite(
$icons,
t3lib_extMgm::siteRelPath('myextension') . 'myextension_sprite.css'
);
As you see it’s quite easy to include the new API, the API provides some further options for overlays and further modifications which I didn’t mention here. And as a final motivation this is a comparison between old and new API to get a “back” button:
// old API
$icon = '<img' . t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/goback.gif','width="14" height="14"') . 'alt="" />';
// new API
$icon = t3lib_iconWorks::getSpriteIcon('actions-view-go-back');
—-
The sprite API is quite new and my knowledge about how to use it is also relatively fresh – so please let me know if you’ve any remarks or questions.
Btw. special kudos for his involvement during the implementation of this nice feature and many many thanks for helping me to understand it, to Steffen Ritter 
—-
Further reading:
—-
Posted: April 1st, 2010 | Author: tolleiv | Tags: crawler, extension, release, typo3 | Comments Off
Nearly a month after version 3.0.5, we published 3.1.0 of the well known crawler extension today. The main work for that step was related to several bugfixes, a better scheduler integration, some CLI-API enhancements, better testcases and (finally) some documentation updates. Most kudos go to Michael Klapper who took over the responsibility for this release and who also fixed a decent amount of bugs.
You can download the extension in the TER and hopefully this time OpenOffice didn’t trick us again and you’ll be able to see a shiny new extension manual on typo3.org as well.
Besides that, Kasper just released the podcast with me talking about version 3.0 of the crawler and about further improvements for the staticpub extension. You’ll find that on typo3.org/podcasts/kasper.
Posted: March 2nd, 2010 | Author: tolleiv | Tags: extension, typo3 | 2 Comments »
TYPO3 is (by definition) a powerful tool when it comes to data. Besides creating, updating and deleting data there are also localizing and versioning, logging and even rollbacks. All this is provided through the GUI of TYPO3 and all the technical stuff in working under the hood of TYPO3 for nearly every piece of data. But what if you’re asked to write a script which imports or updates data, how can you make sure that all this is done in a TYPO3 compatible way?
The lazy programmers approach is to write up SQL, but that’s not what’s recommended if you still want the full TYPO3 featureset to be available for you (without reinventing the wheel). In this case the TYPO3 core class tslib_tcemain (short tcemain) is what you’re looking for. For the mentioned tasks there are two main functions relevant – process_cmdmap() and process_datamap(). The process_cmdmap() performs actions like “move”, “copy”, “localize”, “version” (create, stage, swap, flush), “delete” and “undelete”. The process_datamap() does the rest – creating records, updating datafields. Controlling both of them is done with configuration arrays and that’s how it looks like**:
Creating a record*:
$data = array();
$data['tt_content']['NEW'] = array(
'pid' => 100,
'header' => 'A new thing'
);
$tce = t3lib_div::makeInstance ('t3lib_TCEmain');
$tce->start ($data, array());
$tce->process_datamap ();
echo "The new element has the uid ".$tce->substNEWwithIDs['NEW'];
Creates a new tt_content record on page 100 with the header set to “A new thing”.
Updating data*:
$data = array();
$data['tt_content']['110'] = array(
'header' => 'A really new thing'
);
$tce = t3lib_div::makeInstance ('t3lib_TCEmain');
$tce->start ($data, array());
$tce->process_datamap ();
Updates the header field of the content element with the uid 110 to “A really new thing”.
Move data from one page to another*:
$cmd = array();
$cmd['tt_content']['110']['move'] = 101;
$tce = t3lib_div::makeInstance ('t3lib_TCEmain');
$tce->start (array(), $cmd);
$tce->process_cmdmap ();
Moves the tt_content record with the uid 110 to the page 101.
Copy data from one page to another*:
$cmd = array();
$cmd['tt_content']['110']['copy'] = 101;
$tce = t3lib_div::makeInstance ('t3lib_TCEmain');
$tce->start (array(), $cmd);
$tce->process_cmdmap ();
Copythe tt_content record with the uid 110 to the page 101.
Localize your record*:
$cmd = array();
$cmd['tt_content']['110']['localize'] = 5;
$tce = t3lib_div::makeInstance ('t3lib_TCEmain');
$tce->start (array(), $cmd);
$tce->process_cmdmap ();
This creates a localization for the language 5 of the tt_content record with uid 110 (assuming that the tt_content record 110 is a default language record).
Delete*:
$cmd = array();
$cmd['tt_content']['110']['delete'] = true;
$tce = t3lib_div::makeInstance ('t3lib_TCEmain');
$tce->start (array(), $cmd);
$tce->process_cmdmap ();
Deletes the tt_content record with the uid 110.
Undelete*:
$cmd = array();
$cmd['tt_content']['110']['undelete'] = true;
$tce = t3lib_div::makeInstance ('t3lib_TCEmain');
$tce->start (array(), $cmd);
$tce->process_cmdmap ();
Restores the tt_content record with the uid 110 – if it’s deleted.
—-
* Running the codes requires a TYPO3 backend context with a logged in backend user who has the right to perform all these actions. In addition tcemain has some configuration options to change the behaviour of the actions, e.g. “$enableLogging” or “$bypassWorkspaceRestrictions” – they come with useful defaults but you might need to change them in certain situations ~ so looking into the code documentation might save you some time.
** I left out the “version” part since this requires some more explanation than just a few lines of code.
Posted: October 22nd, 2009 | Author: tolleiv | Tags: extension, release, typo3 | Comments Off
Last Sunday I’ve released the first official stable version of my imagemap_wizard extension (TER).
I though that’s a good moment to review the introduction text on the project-homepage and that’s how it looks like – forge.typo3.org/projects/show/extension-imagemap_wizard
Especially due to the missing/broken TER download counter I’m still not sure whether the work was worth it. I hope some marketing and the given information about all the cool featutes is enough for newbees and TYPO3 pro’s. to switch over to this extension
The 0.6 releases will focus on some UI and usability improvements and looking at my old overall schedule for the 1.0 release there’s “only” one big feature missing – the integration into regular content elements (e.g. “text w/image”). So stay tuned
Posted: September 11th, 2009 | Author: tolleiv | Tags: crawler, extension, typo3 | Comments Off
Cool thing just happend after a couple of months we finally released the new version of the famous crawler extension. Read more on forge,typo3.org