Realurl: define URL for RSS feed


August 27, 2015 at 07:47
Typo3

I wanted to add an RSS feed page with certain information about new articles to an existing typo3 project with an active realurl extension. So I started by defining a new type with the number 888 in my extension:

rssarticles = PAGE
rssarticles {
	config {
		disableAllHeaderCode = 1
		xhtml_cleaning = 0
		admPanel = 0
		additionalHeaders =  Content-type:text/xml; charset=utf-8
	}
	typeNum = 888
	10 = USER
	10 {
		extensionName = PackageExtensionname
		pluginName = RssNewestArticles
		vendorName = Package
		userFunc = tx_extbase_core_bootstrap->run
	}
}

This was now reachable at http://projekt.de/index.php?type=888&id=33 (the page with the ID 33 being just a normal page invisible in the menu) and it did what it was supposed to do. What I wanted to do now was to make this feed available under http://projekt.de/feed.rss or http://projekt.de/rss/ and, naive as I was, I thought that RealUrl would easily be able to handle this. To my chagrin, I was told that "this should better be done via htaccess, realurl is probably not able to do this". WHAT? Really?! I thought this was exactly what realurl was supposed to do?

My first try was to define a feed.rss in realurl_conf.php fileName, but for some reason this didn't allow me to define an ID. Great.

After a long and painful time of searching, I finally decided to settle for a different solution. In the realurl_conf.php I added a type to the preVars:

$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl'] = array(
	'_DEFAULT' => array(
		'preVars' => array(
			array(
				'GETvar' => 'type',
				'valueMap' => array(
					'rss' => 888
				),
				'noMatch' => 'bypass',
				'valueDefault' => 0,
			),
		),
          ...

This isn't enough on its own, because it doesn't allow the setting of an ID and in my case it resulted in a redirect to the start page. So I added the string of page 33 to my URL. Page 33 was called "new articles" and so I called the page via http://projekt.de/rss/new-articles

This makes realurl recognize that page and set the correct ID.

What I learned from this: realurl sucks and the typo3 "community" is a joke. I found several pages where people asked exactly this and none of the typo3 smartasses bothered to answer.


Tags: prevars realurl


Hinterlasse einen Kommentar:
Search