Archive for the ‘Typo3’ Category

Render cObj RECORDS fully or slimmed

Monday, May 24th, 2010

Short share of TypoScript know-how..

TYPO3 comes with a handfull different cObjects, such as TEXT, IMAGE etc.. (see the tsref) and then there are the more general cObjects for content rendering; CONTENT and RECORDS. The CONTENTS object focuses on a more widely rendering process, where you find your data with a select property, and a renderObj output.. ..then there is the little bit simpler variant RECORDS that allows you to find and output records from one or more tables in a bit more raw way thant CONTENT allows you to.. anyway.. what I wanted to share today was this difference when outputing a RECORDS object..

Take this TypoScript:

  1. lib.addressline = RECORDS
  2. lib.addressline.source = 47
  3. lib.addressline.tables = tt_content

It outputs a tt_content record with uid 47 like this:

  1. <div id="c47"><p>My content with uid 47</p></div>

Quite often you might want it a bit more trimmed.. (especially when you map it with typoscript object path in templavoila into a predifend position in a template). Then you can do like this

  1. lib.addressline = RECORDS
  2. lib.addressline.source = 47
  3. lib.addressline.tables = tt_content
  4. lib.addressline.conf.tt_content = TEXT
  5. lib.addressline.conf.tt_content.field = bodytext

Which renders this instead:

  1. My content with uid 47

The basic thing is – define what you want in your output, and ignore the rest. The same could be done with a logotype image or similar (mapping an image content outputs a lot of extra wrappings by default..)

Another small notice; If you map a ts object from templavoila and get HTML output as text, then edit DS/TO and uncheck “as content through htmlSpecialChars (HSC)” for that field….

Generate page as PDF from TYPO3 with the webkitpdf extension

Wednesday, February 24th, 2010

I’ve been digging quite a lot into this thing about generating a TYPO3 page as a PDF file. There are a few extensions in TER that does this in various ways. The two best shots I came up with after some fiddeling was

  • PDF Generator 2 (pdf_generator2)
  • WebkitPDF (webkitpdf)

There are some others but, afaik they lack CSS support.

I started out with the first one, which was really  easy to set up and use, but when I launched it on my production server it throw memory errors, so I started to play with WebkitPDF instead. This extension is a simple but powerfull wrapping around the Wkhtmltopdf project (http://code.google.com/p/wkhtmltopdf/) which basically takes the Webkit HTML engine and generates a print out from that.

The documentation instructs you put the FE plugin on a new page, and then add a short TS into you TS Setup. I thought I’d post my TS setup here for example on how to use it slightly different (mostly since I wanted to have the current page title as filename). Note that I’m forwarding the PDF link to a ts object – lib.pdfLink. I’ve mapped that in an FCE with links in my case. Instead of adding the FE plugin on a separate page I include it on all pages (last row in TS) – since I need the ouput possibility on most pages anyway.

  1. plugin.tx_webkitpdf_pi1.scriptParams {
  2.   print-media-type =
  3.   margin-top = 0mm
  4. }
  5. //set current page title as output filename
  6. plugin.tx_webkitpdf_pi1.staticFileName = TEXT
  7. plugin.tx_webkitpdf_pi1.staticFileName.data = page : title
  8. //generate link
  9. includeLibs.webkit = EXT:webkitpdf/res/user_webkitpdf.php
  10. lib.pdf = USER
  11. lib.pdf.userFunc = user_webkitpdf->user_getPDFLink
  12. lib.pdf {
  13.   //pid =
  14.   linkText = produktblad i pdf-format
  15. }
  16. lib.pdfLink < lib.pdf
  17.  
  18. //include the renderer. we do this on the same page, since we want to fetch the correct page title as filename
  19. page.100 < plugin.tx_webkitpdf_pi1

Additional notes:

I just realized that the CSS attribute page-break-after/before is a bit kinky with the pdf converter (actually it’s the webkit engine, and Firefox has the same problem. I didn’t bother to check if IE suffers from the same, but I guess it does…).
If you want to break a page somewhere, then make sure the page break doesn’t reside in floated elements. This is a bit tricky since a modern HTML template normally consists of floated divs and by that there is no natural position for such page break. This was fairly easy to solve for me in my current case since I really didn’t need the other columns in my output. Therefore I could first set the divs like:

  1. [..general CSS layout setup..]
  2.  
  3. @media screen {
  4. .leftColumn { float: left; }
  5. .rightColumn { float: right; } /*or whatever*/
  6. .pagebreak { visibility: hidden; } /*pagebreak elements should not show up in browser*/
  7. }
  8.  
  9. @media print {
  10. .rightColum { visibility: hidden; }/*dont want it in print mode*/
  11. .pagebreak { visibility: show; page-break-after: always; }
  12. }

I made a small FCE in TYPO3 containing a div with class .pagebreak, which I could insert anywhere on a page. It’s hidden in media screen, but breaks the page when printing. Pritty nifty if you ask me :P

nominate FLOW3 and TYPO3 for SF community awards

Tuesday, May 19th, 2009

Show your support for TYPO3 and the upcoming framework FLOW3 and nominate them for a soure forge community award.

Hit this image to nominate FLOW3 for “Best New Project” and “Most Likely to Change the Way You Do Everything”

..or, hit this button to nominate TYPO3 for “Best Project” and “Best Project for the Enterprise”

There aint much more to say about that ;)

Having a midnight laughter – rebranded TYPO3 newsthread

Tuesday, February 24th, 2009

Stuck in work process I launched Thunderbird to skim through the TYPO3 newslists. Apparently I haven’t checked that one for some time since Thunderbird suggested me to get the latest 500 posts :) Anyway. There was a really funny, or should I say sad, posting about a Russian rebrand/fork of TYPO3. First he uses a pseudonym posting news about a fork, then he denies ‘borrowing’ TYPO3 code and icons, finaly changing into admiting having to change a few lines of code and some icons.. doh.. – check out the site and judge for yourself.

It’s really sad that people just can’t see the fundamental philosophy of TYPO3 and the intentions of it’s original inventor Kasper Skårhöj, releasing his work as GPL:d open source software – Inspire people to share!

I few days earlier I stumbled upon a swedish fork/overlay work of TYPO3 called TYPO3 magenta. I got the similar feelings over this one as with that Russian guys fork. Though this is a bit more balancing on the edge. The TYPO3 name is still there but with a suffix. It’s open stated to be built on TYPO3. From the website (freely translated from Swedish using google..):

“TYPO3 Magenta is a web-based system to manage, organize and publish content on websites. TYPO3 Magenta is a further development of the publishing tool TYPO3. TYPO3 is based on open source which means significantly lower costs compared with commercial counterparts. TYPO3 Magenta has developed with the user in focus. The primary user group is Swedish small-and medium-sized enterprises.”

It’s sold in a license form with system, hosting and support.

But as I said, I find this solution better – while not good. I’m guessing it’s mostly about a nifty back end skinn. Refactoring TYPO3 this way is like saying “TYPO3 is good but old school. We make it modern and better with our own version”. And the main issue is still – what would a company loose going 100% TYPO3 and sharing improvements rather then trying to be so special?

I will be honest. We started our business with two CMS solutions. CMS made simple and TYPO3. One simple CMS for the simple sites and one advanced for the larger ones. We promoted them as simple and advanced cms. However during time I realized that both we and the solutions themselves would benefit much more exposing TYPO3 as it is, with it’s huge community and existing brand name rather then trying to make it seem more like our own, and so far it’s just been true. I think that the more credibility and reward the community gets for it’s efforts the better TYPO3 will be.

After all, the community is a vital part of TYPO3 together with it’s open source base. Alongside with that TYPO3 is also a very strong brand and should be promoted and empowered so.

Inspire people to share! – it will get us so much further

Typoscript code completion in TYPO3 version 4.3a1

Tuesday, February 10th, 2009

Finally I took a quick test of TYPO3 version 4.3 alpha 1. Read the link for a detailed release info. However I’d like to highlight one update a bit extra for you. The TypoScript editing extension that made life prittier highlightning and helping out with the indentation for the TS code when editing has now got itself a usefull and very nicely implemented code completion function. Look at the image below.

It’s perfect for people like me that just cant get all those object and attribute names to stick in memory.

Code completion in TYPO3 v 4.3

Now, I’m having a hard time waiting for next alpha or maybe beta so I can test the new front end editing fuzz which at least seems awsome!. Check it out at Jeff Segars blogg.

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!

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 = "&amp;edit[$mapTable][123]=new&amp;defVals[$mapTable][name]=banana&amp;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.prod.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.