Apply sorting for Extbase ObjectStorage

I, andmanyothers, had the issue that it’s not possible to apply a default sorting for child objects of the type Tx_Extbase_Persistence_ObjectStorage with extbase. For exmpale, I happen to have a “course” object which stores “event” objects. The default getter would just

return $this->events;

without no possibility to define in what ordering the objects are returned.

Setting the default ordering in the event repository has no effects whatsoever. But the problem is actually pretty easy to solve. Just create an instance of the child object repository in the parent model and then you can use the default findBy methods. Lets say your parent object is called “Parent” then you’d use findByParent($this->getUid());

In the child repository apply your sorting and do whatever you like:

Remove empty P tags before and after RTE content in Fluid Templates

I stubbled across this today on a clients page; I used f:format.html to pare some rte content. Somehow there where empty <p> tags before and after the content. At first I thought the RTE was at fault. But then I realized the problem was in my template;

<f:format.html>
{rtecontent}
</f:format.html>

The linebraeaks before and after the fluid variable ‘{rtecontent}’ are responsible for the additional <p>’s. Conclusion: Don’t use linebreaks when you use <f:format.html>, instead use this:

<f:format.html>{rtecontent}</f:format.html>

Default language for domain with Typo3

I just figured out how to configure a default language for multiple domains in Typo3 with TypoScript. Its pretty easy actually – no fuss with realUrl. It checks for the HTTP_HOST when no L Parameter is set:

# Default language, sys_language.uid = 0
config {
sys_language_uid = 0
language = en
htmlTag_langKey = en
locale_all = en_US.UTF-8
}
[globalVar= GP:L=1] || [globalString= IENV:HTTP_HOST=*.de, IENV:HTTP_HOST=*.ch, IENV:HTTP_HOST=*.at] && [globalVar = GP:L=]
config {
sys_language_uid = 1
language = de
htmlTag_langKey = de
locale_all = de_CH.UTF-8
language_alt = en
}
[global]

Check out the Snippet at typo3.org