Archive for the ‘Development’ Category

TYPO3 commerce extension finally shows prices for me

Tuesday, December 30th, 2008

I’ve actually had trouble with this for quite some time. I’m using the commerce extension for TYPO3 for a site. The plan is to turn the site into an e-com site eventually, but starting of with plain product listings so I thought I’d give the commerce extension a shot. It’s quite comprehensive. Amongst a lot of things it has a good internal structure to allow all kinds of variants of an article – especially suitable for things like textiles where you have a combination of color and sizes making an article.

One big downside I feel currently is the template setup. It’s heavily templated, but still not really as flexible as I’d like. Could be a competence/knowledge issue – but nah! I’m smart! really..

However I’ve had some real troubles showing the prices. Really. Seems so basic, but I just couldn’t get into it. Today I logged into the #typo3 channel @ freenode irc. Thanks to friendly help from PiMB there I got it working. It all had to do with setting the currency. I ended up with this in my TS:

  1. plugin.tx_commerce_pi1.currency = SEK
  2. plugin.tx_commerce_pi2.currency = SEK
  3. plugin.tx_commerce_pi3.currency = SEK
  4. plugin.tx_commerce_pi5.currency = SEK

The default for ..pi1.currency was – “currency” – and not a real currency – like SEK or EUR. That’s all. the other FE commerce plugings actually has EUR as default.

Anyway. by this post I’d like to state that the open source community is (at least around TYPO3) very friendly and helpsome. – and – thanks PiMP for the hint ;)

The site – still in a bit of progress (have some wierd positioning in the templates) – can be found here (swedish) http://www.byylva.se/. High quality carpets and other textiles :)

cheers. And a happy new Year!

Adobe CS4 is down for counting

Wednesday, December 10th, 2008

As soon as Adobe CS4 was released we got our hands on it. Since I’ve been doing quite a lot Flash things lately I was hoping the new version would reveal some greate new features. However after trying it for couple of weeks now, I can only summarize the experience as; grumpy. To begin with Flash crashes for me when opening most of my old cs3 files, doesn’t recognize an old flash project file (.flp), crashes totaly if I’m to fast clicking around (hey.. it’s fun to click around with the mouse). The last behaviour is the same for the other nifty tools such as Illustrator and Fireworks.

They die right in front of me leaving me with a broken (long-time-since-last-save) file. Some say it’s about fonts, some say it’s about somethingelse. I saw someone who solved it by buying a new computer..

I contacted Adobe in for the subject, posted an error report and gave them full dumps of my machines current state.. getting the reply to go through a bunch of help yourself links with twenty steps each! Things like that make me grumby.

Anyway.. I’ve tried reinstalling the entire CS4 premium package (uninstall and install taking for ages) without success.. and yeah. one last thing.. Acrobat reader now crashes if I try to open a pdf link within the (a/any) browser. Thanks..

regards,
A grumpy web developer

editing PHP with NetBeans IDE

Monday, October 27th, 2008

I admit. I’m an IDE and RAD lover. And I enjoy trying out new development enviroments all the time in the quest for the perfect work tools. After using Eclipse for quite a long time for PHP, I switched to Activestate’s Komodo 4.4 IDE. Komodo is a really nice and slick IDE with by far the best PHP code completition I’ve found in any tool. The debugging is easy to setup using xdebugger and it’s easy to analyse your code using watches and analysing tools. One tool I found useful was the Watch file tool wich could be compared to the tail -f command in Linux (allows you to ‘stream’ the data of a file to output. useful to analyze log files on the fly for instance).

However, I think Komodo suffers a bit from a ruff UI, loosing variables and values in debugging sessions, forgets it’s line position and break point positions from time to time and has a limited subversion integration.

Then I found NetBeans early access for PHP. This was a really nice surprise, however I couldn’t get debugging working so I switched back to Komodo again. But now Netbeans.org released the RC1 of version 6.5. After some fiddeling I got the debbuger working (I guess it really didn’t have to do with rc1 but still..) and by that I’ve got my new favourite environment. Main advantages are for me:

  • The debugger is the best PHP debugger I’ve tried.
  • A slick and fast UI. Very easy and intuitive to rearrange panels and views almost in any way I’d like
  • Superb subversion support. Direct markers for changes, easy shortcuts to view diffs and revert actions.
  • Good refactoring support (things like Ctrl+R to refactor a variable etc).
  • Built in SQL editor with code completion
  • Active and easy class/property inspector (Komodo lists all open files, Netbeans shows only active or selected file in file list without opening it)
  • and so on..

A screen shot attached, editing a TYPO3 ext project for a client.. note the SVN popup..

coding PHP with NetBeans 6.5 RC1

TYPO3 Bug day the 29th of august

Wednesday, August 27th, 2008

TYPO3 bug hunt day is an official day with an official IRC channel for hunting down bugs together. I missed the first two bug hunting days, but this time I really hope to be able to help out. I like the initiative of a bug day to get the general community more involved into TYPO3. Let’s hunts some bugs shall we? (c’mon. join me :P )

T3CON08, here I come

Sunday, August 24th, 2008

Me and my colleague decided to register for the annual TYPO3 conference – t3con08. This year it’s taking place in Berlin, which will be cool as I’ve never been there. But the best part will hopefully be to meet a lot of TYPO3 users and developers – perhaps even one or two from freenode channel #typo3 where I’m hanging around from time to time.

Not only did we register for the conference but also to become association members for Merea, our company, which feels like the right choice to do as we focus our business more and more around TYPO3 services. It’s a good way of giving back something to the product and community as well as taking further engagement with TYPO3.

So, I hope to meet a lot of friendly faces and get loaded with inspiration and knowledge.

create new record link with TCE

Friday, August 8th, 2008

If you need a ‘create new record’ link in BE of TYPO3 and also need to supply some default values, this is the way;

  1. $params = "&edit[$mapTable][123]=new&defVals[$mapTable][name]=banana&defVals[$mapTable][codename]=hajaja";
  2. $aOnClick = t3lib_BEfunc::editOnClick($params,‘../../../../’.TYPO3_mainDir);
  3. $icon = ‘<img’.t3lib_iconWorks::skinImg($this->doc->backPath,‘gfx/edit2.gif’,).‘ title="Create secret agent" alt="" style="border:0;" />’;
  4.  
  5. //print a pen icon with the link
  6. $HTML = ‘<a href="#" onclick="’.$aOnClick.‘">’.$icon.‘</a>’;
  7.  

So, what we do is setting up necessary parameters for alt_doc.php to perform cmd actions. In this example I use;

edit[table name][uid OR pid OR -uid]=command – use uid and the command edit to edit a uid, otherswise (as I do  above) use pid and new as command to create a new record in a certain pid. A negative uid together with the new command Creates a new record right after the supplied uid.
defVals[table name][table column]=value – two times. This sets default values for my two fields; name and codename.

Then assemble the parameters with the TYPO3 API call t3lib_BEfunc::editOnClick(); into a javascript call.

Getting rid of typohead tag in the tiny rte

Wednesday, July 9th, 2008

I can honestly say that I’m no expert in the typoscript part of TYPO3. I realised this when I tried to find a solution on not using the Hx <-> <typohead..> tag transformation with the RTE. Took me hours to find the solution, but as mostly with typoscript, it’s quite simple. The brutal way was to add a pageTSConfig

RTE.default.proc.typohead = 0

But that just disables the use of typohead right off, breaking all current content on the site. And when reading a bit more I realised that what I really wanted was to use another transformation method than the default set for tinyrte;

RTE.default.proc.overruleMode = ts_css

This nicely allows the typohead tags stored in DB to be there, get transformed to Hx when opened with the rte and then when saved, never seen again :)

The overruleMode sets the general transformation mode that the rte should use, and afaik ts_css is to be the modern way of transforming data. The ts_css mode is actually a meta mode for a bunch of transformation rules. See the RTE reference for in depth know how about that.

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.

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.