Wednesday, 26 February 2014

TYPO3 - TSref optionSplit

Taken from the TYPO3 wiki:

The main TypoScript-syntax is
...first part... |*| ...middle part... |*| ...last part...
with each part being
...subpart || subpart || ... || subpart...
Rule 1, the priority is 1-last part, 2-first part, 3-middle part
Rule 2, if the middle part is absent, the last subpart of the first part is repeated in order to fill values. To indicate that the middle part is absent, it's necessary to write with no spaces, as
|*||*|
Rule 3, if the first and the middle parts are absent, the first subpart of the last part is repeated.
Rule 4, if the last part is absent, the middle value is repeated
a a a a a
a || b || c a b c c c ...
a || b |*| c a b c c c ...
a || b |*| c |*| d || e a b c c ... c c d e Rule 1
a || b |*| c |*| d || e a b d e Rule 1
a || b |*| c |*| d || e a d e Rule 1
a || b |*||*| c || d a b b c d Rule 2
|*||*| a || b a a ... a b Rule 3
a |*| b || c |*| a b c b c b c ... b c Rule 4

Wednesday, 9 January 2013

Typoscript condition cookie check

Need to display/hide content based on cookies? Use the following:

[globalString = _COOKIE|cookie_name = cookie_value]
...
[global]

Thursday, 11 October 2012

TYPO3 menu link to subdomains

When you have a site setup like this:

example.com [Root level with own domain]
          |- sub1.example.com [Root level with own domain]
          |-- Page 1
          |- sub2.example.com [Root level with own domain]
          |-- Page 1
And you want to have a shared menu like:
Main Site
Sub 1
Sub 2
which works correctly between the sites simply set
config.typolinkCheckRootline = 1
in your top level template and it should work correctly.

Monday, 20 August 2012

Typoscript nested if

Sometimes I need to have nested (AND) if statements in typoscript. I often try using the following:

10 = TEXT
10.value = Foo Bar
10.if.value = Foo
10.if.equals = Foo
10.if.isTrue.if.value = Bar
10.if.isTrue.if.equals = Bar

Which will fail to work at all. Why? The nested if must return something for the isTrue to work, so adding the line:

10.if.isTrue.wrap = 1

will fix the problem.

Thursday, 16 August 2012

Custom content split issue

I occasionally run into an issue when trying to use a split on a custom generated CONTENT object.

Have a look at this code:

temp.groups = CONTENT
temp.groups {
  table = fe_groups
  select {
    pidInList = {$groupStoragePid}
    andWhere.dataWrap = FIND_IN_SET(uid, "{TSFE:fe_user|user|usergroup}")
  }
  renderObj = COA_INT
  renderObj {
   10 = TEXT
   10.dataWrap = "{field:title}"###SPLITTER###
  }
}

page.10 = COA_INT
page.10 {
  10 < temp.groups
  10.stdWrap.split {
    token = ###SPLITTER###
    cObjNum = 1
    1 = TEXT
    1.current = 1
  }
}


You would expect the above code to strip the ###SPLITTER### tags out, but it doesn't. Why not? I've set the renderObj of the CONTENT to COA_INT, which causes the split to fail. Changing the renderObj to just COA fixes the problem. I'm not actually sure why, I haven't looked at the source, but I'm assuming it's something to do with the order in which the CONTENT object is processed when no caching is set.

Monday, 23 July 2012

TYPO3 Backend Layout Control

I'm using TYPO3's backend layout feature on a multi site install. This meant that I was seeing every backend layout I'd set up on every page in every site, which isn't ideal. So how do you control which backend layouts are available? TSConfig of course!

TCEFORM.pages {
  # Storagepage of layouts
  backend_layout.PAGE_TSCONFIG_ID = 0
  backend_layout_next_level.PAGE_TSCONFIG_ID = 0
}
Obviously replace 0 with the PID of the page where the backend layout records are stored.

Saturday, 10 March 2012

TYPO3, character "" not allowed in prolog

This problem can also cause the error:
Error: no internal or external document type declaration subset; will parse without validation

Basically what is happening is the browser cannot read the document type and renders in quirks mode. This will often break your layout, in my case it completely broke the functionality of the site (ColorBox was borked).

The most likely solution? Convert any files with the encoding UTF-8 to UTF-8 without BOM. Some text editors automatically add the BOM, which is what happened in my case.