November 20th, 2007
Ajax is definetly the thing to go with the web as it enhance the user experience as well as allowing more logic to be on the server side (okey, your pages javascript usualy tend to get slightly more bloated as well..).
Anyway. It’s not ajax in general today, but the good looking PHP/ajax combination found with the xajax project. Xajax allows you to have PHP functions that you mapp/register as javascript calls. There is an extension for TYPO3 called – xajax! You guessed it! There are two tutorial/example extensions as well that describes how it works. But for my memory I’m writing a short guide here as well with my own words. Maybe it helps someone else.
Using ajax in your backend module:
- Do the obvious. Install the xajax extension from TER (ie TYPO3 Extension Repository).
- Launch your favourite editor and open your module file like – /typo3conf/ext/myext/mod1/index.php
- Include the ajax class
-
// DEFAULT initialization of a module [BEGIN]unset($MCONF);require_once(‘conf.php’);require_once($BACK_PATH.’init.php’);
-
require_once($BACK_PATH.‘template.php’);
-
// include XAJAX class library
-
require (t3lib_extMgm::extPath(‘xajax’) . ‘class.tx_xajax.php’);
-
$LANG->includeLLFile(‘EXT:myext/mod1/locallang.xml’);
-
…
- Somewhere in your init() method register your PHP function
-
$this->
xajax->
registerFunction(array(‘xajaxTest’, &
$this,
‘xajaxTest’));
- In your printContent() method add this to ensure that xajax does whatever it wants (ie handle requests..) first
-
$this->xajax->processRequests();
- Then create your nifty PHP function where you want to do magic, and add a responce object like this:
-
function xajaxTest() {
-
$c = "ohlas!";// Instantiate the tx_xajax_response object
-
$objResponse = new tx_xajax_response();
-
$objResponse->addAssign("mydiv","innerHTML", $c);//return the XML response generated by the tx_xajax_response object
-
return $objResponse->getXML();
-
}
- Now finally add a call to your function. This is probably done in moduleContent() or referenced functions
-
<a href="#" onClick="xajax_xajaxTest();">xajax magic</a>
Note that we got an extra xajax_ added to the beginning of our function which is added automatically.
That’s it folks!
Posted in PHP, Typo3 | No Comments »
October 24th, 2007
The absolutely best advantage of using a Linux/*nix based OS is the shell applications and functions. I’m quite far from good at utilising it. I guess it mostly depends on that you need to use it often to remember all the flags and things. Still usefull and quick when you know your way around. Take for instance this simple line of command:
find . -cmin -20 -ls
This list all files in the current folder that are modified within the last 20 minutes. Nifty and quite basic. Your number one resource to getting to know the commands is the man command (man like in manual)
man find
And you know how you do it..
Posted in Linux things | No Comments »
October 3rd, 2007
A short one. TYPO3 is amazing when (amongst other things) it comes to localization of website contents. The documentation is quite good to around the subject, which is quite rare when it comes to TYPO3 otherwise. However, today I had totaly forgotten how to, or even if it was possible to, only localize the text part for text w/image elements. After some reading I found this great typoscript key
-
config.sys_language_softMergeIfNotBlank = tt_content:image, tt_content:header
What this actually does when put in you TS template (together with the rest of the localization settings) is saying that TYPO3 should softly and nicely merge the image and header fields of a content element if it’s not translated into the other translated materials.
Go TYPO3 I say
Posted in Typo3, Typoscript snippets | No Comments »
June 15th, 2007
I’ve modified the TYPO3 extension vc_javascriptslideshow from ground up. The vc_javascriptslideshow is a javascript/css based slideshow that flips images and I needed to be able to control it fully from TS. That ended up in adding a few extras as well.
The extension now includes
- added full support for TS configuration
- added support for multiple slideshows on one page
- Added settings for border and background for the slideshow (stylesheet settings on a surrounding div)
- Changed the file rezise to use IMG_RESOURCE instead of custom exec of IM and now use width/height attributes there. This makes it also possible to define w/h as ie 200m or 200c for cropping or relative resize (see the static ts template).
- added support to (in TS only so far) define a path from where all images should be taken.
TypoScript example setup, included via TV element:
-
-
lib.topBanner < plugin.tx_vcjavascriptslideshow_pi1
-
-
lib.topBanner {
-
//specify path from where to fetch images
-
imagesPath = fileadmin/bilder/banners/
-
//..or a use a specified list of images
-
// imagesList = Vinter.jpg,Solnedgang.jpg
-
altText = informationsruta
-
imageWidth = 500
-
imageHeight = 70c
-
//override imagesList to fetch all images
-
getAllFromPath = 1
-
//number of millisecond for each transition
-
msTransitionDelay = 140
-
//background color for slider space
-
#backgroundColor = #ccc
-
//a possible border if you like
-
borderSize = 0
-
}
-
The extension probably contains some bugs, but works for my purpose. I will try to add some documentation soon.
I have e-mail the original author hoping that he will include it in the official release. Otherwise I’ll probably add a new ext.. (*hrhr*).
Download the modified ext. (unpack, upload and update ext in EM).
Posted in PHP, Typo3 | 1 Comment »
June 4th, 2007
I’m using irc quite often and most of the time I use the ChatZilla client for that. Normally chatzilla is an extension to Firefox (-ish browsers), but it can be quite annoying to have it tied up to your browser. Quitting the browser quits your irc-session.. Now I found the cure for it – XULRunner. It seems to work like a charm and it’s easy to setup.
I did these steps in cmd shell (yes in Windows XP) after downloading XULRunner and solo ChatZilla zip packages:
-
C:\Program>cd xulrunner
-
C:\Program\xulrunner>xulrunner.exe –register-global
-
C:\Program\xulrunner>xulrunner –install-app c:\download\chatzilla-0.9.78.1-xr.zip
-
C:\Program\xulrunner>xulrunner –install-app c:\download\chatzilla-0.9.78.1-xr.zip "c:\Program\Mozilla Firefox" chatzilla
By this it ends up in it’s own folder in the Firefox structure.
Posted in web life | No Comments »
June 2nd, 2007
Actually, I didn’t find an old cup of coffee (even if that can happen once in a while) but while talking to some friends of mine today I got this stupid desire to do some java game development. As if I would have time to do that. Well, despite lack of time I’ve come to realise that I’m also lacking knowledge of java in general and game construction in specific. What an adventure.
The first thing I usually do when I’m about to start of with a new project based on technologies or ideas that’s normally of topic for me, I turn to my friend google. This time the search term was ‘java game development’ *puhe*. I found two rather interesting urls in the result – Robocode (http://robocode.sourceforge.net/?Open&ca=daw-prod-robocode) and and Light Weigh Java Game Library (www.lwjgl.com). Check ‘em out. I’m seriously thinking of getting into the lwjgl library, but honestly – how far do I really think my game dev plans will go? :S nahh. clasic double buffer repaint will do for me.
The other link – Robocode – sound really nerdy and fun. Hopefully there will be time to play with that as well.
Ok. So what’s my big plans? The great game plot? Well first, or rather simultaneously, I will together with two other friends start to build a network camel racing game… and secondly I will try to revitalize an old game idea called TWISEM. I let you know the meaning of that acronym later..
So, stay tuned. Maybe an applet game or similar may popup here within a year or so..
Hm, yeah. I think I would make it with flash today and not java but it just ain’t as cool…
Posted in Development, Java | No Comments »
March 8th, 2007
We’ve been working on a site for a customer for some time now based on TYPO3. As the the respect to typographical issues where important we decided to go forth using GMENU and GIFBUILDER for menus and headings. I really like the concept of GIFBUILDER and working with it. Sadly we got problems with non ascii characters like our swedish åäö and such. They where replaced by ugly boxes.

So, why on earth did this happend I questioned my self.. and people on #typo3 @ irc.freenode.org.
I ended up with these suggestions/requirements:
- Make sure you use utf-8 all the way. Gifbuilder (probably GD/freetype really)
- Check that the font you use is unicode
- Check configuration for mbstring (or iconv) that gifbuilder uses
I did all this. Utf-8 was a requirement for the project as the site will be on both chinese, swedish and english. The font seemed to be in Unicode as well (as far as I could tell). And mbstring was working like a charm..
It’s importent to mention that the development server was a windows server.
Anyway. I copied the site to my local windows computer and tested it. The same buggy result. The I copied it to my own webserver running on debian linux and there it worked! Why? Donno.. However. I went back to my local computer and replaced the font with arial. I got nifty åäö all the sudden. This at least allowed me to assume that it had something to do with the font file (a .otf file btw). The only solution I could think of now would be to convert the font hopfully to utf-8. I got merely no experience with typographical things so this was a blank area for me, but after som googleing I stumbled upon fontforge (http://fontforge.sf.net). It’s actually a *NIX application but I installed Cygwin (along with xfce4), and the cygwin port of fontforge. Wow what an app! A really crappy gui, but wow!

So, I went on and converted my .otf font forcing it to Full unicode, replaced it in my exsisting font on the site. It worked like a charm!
My final configuration on every aspect turned out like this:
localconf.php:
-
-
// UTF-8 support
-
$TYPO3_CONF_VARS[‘GFX’][‘gdlib_2′] = ’1′;
-
$TYPO3_CONF_VARS[‘BE’][‘forceCharset’] = ‘utf-8′;
-
// For GIFBUILDER support
-
// Set it to ‘iconv’ or ‘mbstring’
-
$TYPO3_CONF_VARS[‘SYS’][‘t3lib_cs_convMethod’] = ‘mbstring’;
-
// For ‘iconv’ support you need PHP 5!
-
$TYPO3_CONF_VARS[‘SYS’][‘t3lib_cs_utils’] = ‘mbstring’;
-
// For Asian languages
-
$TYPO3_CONF_VARS[‘SYS’][‘multiplyDBfieldSize’] = 3;
-
//force db communication to utf8
-
$TYPO3_CONF_VARS[‘SYS’][‘setDBinit’] = ‘SET NAMES utf8;’;
-
Typoscript
-
-
-
## GIFBUILDER HEADING RENDER SETUP ########
-
##
-
##### Header 1
-
cHeader1 = IMAGE
-
cHeader1 {
-
alttext.cObject = TEXT
-
alttext.cObject.field = header
-
wrap = <div class="h1gfx">|</div>
-
file = GIFBUILDER
-
file {
-
format = gif
-
reduceColors = 15
-
transparentColor = #ffffff
-
XY = [10.w]+2,[10.h]+8
-
backColor = #ffffff
-
10 = TEXT
-
10 {
-
text.field = header
-
fontSize = 14
-
offset = 0,20
-
fontColor = #333333
-
fontFile = fileadmin/fonts/NewsGothicStd_utffull.ttf
-
antiAlias = 1
-
value.case = upper
-
}
-
}
-
}
-
Database was set to full utf-8 charset in all tables from the beginning.
See http://wiki.typo3.org/index.php/UFT-8_support about utf-8 support for TYPO3.
Posted in Design/graphics, Typo3, Uncategorized | 3 Comments »
March 1st, 2007
I just recently found out about Delphi for PHP – a PHP RAD environment. Actually the first real PHP RAD environment I’ve seen. Delphi was (and still is I guess) a fast and easy to use RAD for MS Windows solutions based on the the Pascal language. I more or less started my programming path with Delphi so there are special feelings still there for it
Delphi for PHP can be found at http://www.codegear.com/products/delphiforphp. Take a sneak peak at the demos. I really like the table grid and database connection.
I think that a RAD like Delphi for PHP is a great thing for the PHP language though not required. But developing complex, custom tailored solutions for your clients by hand is time consuming and demanding even if you use frameworks like cakePHP or symfony (which both are really great btw). Using some kind of IDE like eclipse (with php plugin), PSPad or JEdit is a requirement for any development.
What I fear is that I might loose to much control over the source code and it’s parts. To much happening automaticaly. A bit like using Microsofts development tools
. I’m also a bit worried when using proprietary libraries like the vcls as I can’t enhance or redefine them in the same way as with open source ones. The good thing here on the other hand is that these libraries are object oriented and therefore easily extendible. Thinking of it, it would also be interesting to know a bit more about layout support and application flow controls.
Well I’m hoping to fetch a trial of it before I mumble to much about pros and cons.
So please codegear. Release a trial version so we can give it a spinn. I’m definitely considering to start use it. If it can increase productivity and efficiency, while still leaving me with full control over my sources it’s worth a lot. I’m ready to let go of total control and “notepad mentality” in benefit of that. Maybe I might actually be able to start earn some money on the projects then.
Posted in Development, PHP, editors/ides/rads | 3 Comments »
February 28th, 2007
Well. I’m David. See http://www.merea.se/ (swedish) if your curious on what I do for a living.
Posted in Uncategorized | 1 Comment »
February 19th, 2007
I recently had to change the title of my files in filelinks with typo3. As I’ve become customed with the thought of having mostly either a full or partial solution to every problem with Typo3, I headed off to google and looked for ways to modify the filelinks.
This got me to css_filelinks. A nice way to modify most appearance aspects of filelinks. I think it’s actually a good example of how T3 can be modified by behaviour and function.
Anyway, with that one you can change the FE (FrontEnd) display to your likening with a template/marker styled way. Instead of displaying ###TITLE### (filename) I choosed to use the description field that you can add in the filelinks setting.
-
-
tt_content.uploads.20.layout.file >
-
tt_content.uploads.20.layout.file.cObject=COA
-
tt_content.uploads.20.layout.file.cObject{
-
wrap=<div class="filelinkslist">|</div>
-
10 = TEXT
-
10.wrap=<span>|</span>
-
10.value=###ICON###<a href="###URL###">###DESCRIPTION###</a>
-
20 <.10
-
20.value=###FILESIZE###
-
}
-
Configuration reference: http://typo3.org/documentation/document-library/extension-manuals/css_filelinks/0.2.11/view/1/3/
Posted in Development, Typo3, Typoscript snippets | No Comments »