Home

Tag-Archive for » TypoScript «

TypoLink: Tiny Helpers To Save The Day #1

Thursday, July 17th, 2008 | Author: Benni

I more and more enjoy the power of TypoScript. Every day, I learn something new. I will

Tip 1: You want to link to the same page, but with JS params etc,

lib.mytext = TEXT
lib.mytext.value = This is a link
lib.mytext.typolink.parameter = {TSFE:id},775 500x600 selflink
lib.mytext.typolink.parameter.insertData = 1

I had to use this idea when having a big site with a lot of microsites where the client is able to clone a microsite without needing to configure any IDs. The typolink.parameter = this,775.. did not work.

Basically, with this project, I had to make sure that no page IDs were hardcoded in TypoScript, so it was easy to create a new site inside TYPO3.

The following example renders a menu based on keywords (there was a requirement about the page titles) instead of a special = directory type of menu.

lib.rightnav = HMENU
lib.rightnav {
  special = keywords
  special {
    value = 1
    depth = 2
    setKeywords = Contact,Newsletter
    keywordsField = title
    entryLevel = 0
  }
  1 = TMENU
  1 {
    alternativeSortingField = sorting
    noBlur = 1
    NO.allWrap = <li>|</li>
    wrap = <ul class="rightcol_contact">|</ul>
  }
}

The next example shows a tt_news to link to the first subpage as the “single page”.

plugin.tt_news.singlePid.cObject = HMENU
plugin.tt_news.singlePid.cObject {
	special = directory
	special.value.data = TSFE:id
	maxItems = 1
	includeNotInMenu = 1
	1 = TMENU
	1 {
		NO.doNotLinkIt = 1
		NO.stdWrap.field = uid
	}
}

I know it’s not big magic and can be solved differently as well, but it just keeps me busy these days :)

Category: TYPO3 | 2 Comments

When switching from baseURL to absRefPrefix…

Tuesday, July 01st, 2008 | Author: Benni

My latest thing to do is switching my TYPO3 installations from baseURL to absRefPrefix. Ever since this awesome extension realURL was written, there was the need to define the URLs that should be relative to the TYPO3 main directory. Imagine having a TYPO3 installation running under a domain called www.b13.de. Without realURL your TYPO3 generated URLs looked like:

http://www.b13.de/index.php?id=25

Well, we all know that search engines don’t like it and visitors don’t find it as convenient as having a real URL, that looks like that

http://www.b13.de/en/about/downloads/
http://www.b13.de/en/products/saviour-v1/

Great! Let’s do this. RealURL does everything for you. Very simple and good (and bug-free — I love the latest version, thanks Dmitry!). However, if you’re on the downloads page and want to link to the products detail page, then the link will look like

http://www.b13.de/en/about/downloads/en/products/saviour-v1/

The reason is that realURL (or let’s say, your browser) does not know where the root of your installation is. realURL suggests using the <base href=”http://www.b13.de/”> tag to let the browser know that all relative links are relative not to the current page but to the specified base href. You can configure this in TypoScript with config.baseURL = http://www.b13.de/ and then there you go.

This all works fine — and if you have multiple domains, you just need to use TypoScript conditions, but this is all doable. However, in the recent past a few of my clients (NOTE: only the ones with 404 pages managed through TYPO3) ran into problems with strange floods of their log files with zillion 404 calls. The reason was that there are some bots that don’t interpret the baseURL tag, and then call the non-existent URLs (e.g. images), which redirect to the 404 which also includes the 404 path. Yes, quite annoying.

So, I was searching for an alternative. Dmitry posted some information on his blog about this error as well. The htaccess redirect he mentioned worked just fine, but I really wanted to avoid this in general, asking a simple question: “Can’t I just set a slash (/) in front of every URL and file reference of my generated HTML?”. This was something I actually wanted before I used this baseURL configuration option (yes, a long time ago). And, in fact, there was this option “config.absRefPrefix” lying around the whole time, and I never used it. As you can see there are so many things you find every time in TYPO3. With the absRefPrefix option I don’t even need to bother with the domains if I just use

config.absRefPrefix = /

or

config.absRefPrefix = /path/to/my/t3installation/

depending on the location of the TYPO3 mainsite directory. But it looked like it’s not that easy, because I ran into some issues (after switching 4 or 5 sites from baseURL to absRefPrefix).

  • You need to have the latest realURL version and set the “reapplyAbsRefPrefix = true” in your realURL configuration array to keep the prefix.
  • Linking between domains is not as smooth anymore as with the latest realURL and 4.2
  • If you have references to typo3conf/ext/, they won’t be prefixed. I ran into this by having: <link rel=”stylesheet” type=”text/css” href=”typo3conf/ext/rgmedialinks/res/mediabox.css” />. I noticed that this is a bug in the TYPO3 core, so I fixed it.
  • There are still some errors if you use custom extensions. You need to make sure that these work. I had trouble with mailforms and some custom scripts that alter the “img” tag, because the URL wasn’t typo3temp/ anymore but http://www.b13.de/typo3temp, so some default replacements didn’t work anymore. Nothing serious, but just something to keep in mind.
  • The latest issue that the Magic images I added during the baseURL times with the htmlarea RTE didn’t work anymore. A simple htaccess redirect (RewriteRule ^(.+)uploads/(.*?)$ /uploads/$2 [R,L]
    ) worked just in this case.

In my eyes, the real and true solution would be to

  1. get rid of all baseURL tags (in my eyes, it was and will always be just a dirty workaround).
  2. have realURL add the part of the mainsite directory to every relative path when rendering the HTML. There could be an option for multisites to dynamically add the domain to all links, using the domain records.

Category: TYPO3 | 7 Comments

TypoScript Magic: tt_news Title in Headline or Menu or somewhere

Friday, June 06th, 2008 | Author: Benni

In almost every TYPO3 project of mine, I use this awesomely generic tt_news for displaying news, top offers, etc. In many projects I also have a headline or a breadcrums menu somewhere, telling about the title of the page. tt_news itself offers the possibility to substitute the page title in the <title> tag, however I often use my own title tag rendering, or by using the excellent seo_basics extension :). So the tt_news title is not substituted at all. Therefore I always wrote this little TypoScript snippet that I can use everywhere: more…

Category: TYPO3 | 8 Comments

Evolution Of My Footer Code - Part 1

Tuesday, June 03rd, 2008 | Author: Benni

Everybody started out very simple with TYPO3. In case of my projects, I had to update the copyright year, with all my clients of course. At first, I put everything static in my HTML template, so I had to change the year there. Then I put the static string in TypoScript. Nowadays I enjoy the power of TypoScript that automatically updates the year in the footer for me. This means less client calls at the beginning of the year :) more…

Category: TYPO3 | 3 Comments