typo3 - How to omit empty (optional) segment in realurl? -
currently i'm trying create nice looking url's custom extension.
i using plugin on page "products" (uid: 3) list categories.
for example there following categories:
- men
- shirts
- sweatshirts
- women
- shoes
- dresses
i'd have these corresponding url's:
www.mydomain.com/products/men.html
www.mydomain.com/products/men/shirts.html
this is, get:
www.mydomain.com/products//men.html
www.mydomain.com/products/men/shirts.html
the category "men" on first level not have parent category, segment remains empty. there parent category, fine.
typo3 version: 7.6.15
realurl version: 2.1.6
this current configuration fixedpostvars:
'fixedpostvars' => array ( // ext: productsdb start 'productsdbconfiguration' => array( array( 'getvar' => 'tx_productsdb_categories[action]', 'valuemap' => array( ), 'nomatch' => 'bypass' ), array( 'getvar' => 'tx_productsdb_categories[controller]', 'valuemap' => array( ), 'nomatch' => 'bypass' ), array( 'getvar' => 'tx_productsdb_categories[parent]', 'lookuptable' => array( 'table' => 'tx_productsdb_domain_model_category', 'id_field' => 'uid', 'alias_field' => 'title', 'addwhereclause' => ' , not deleted', 'useuniquecache' => 1, 'useuniquecache_conf' => array( 'strtolower' => 1, 'spacecharacter' => '-' ), 'languagegetvar' => 'l', 'languageexceptionuids' => '', 'languagefield' => 'sys_language_uid', 'transorigpointerfield' => 'l10n_parent', //'autoupdate' => 1, //'expiredays' => 180, ), // 'valuedefault' => '', ), array( 'getvar' => 'tx_productsdb_categories[category]', 'lookuptable' => array( 'table' => 'tx_productsdb_domain_model_category', 'id_field' => 'uid', 'alias_field' => 'title', 'addwhereclause' => ' , not deleted', 'useuniquecache' => 1, 'useuniquecache_conf' => array( 'strtolower' => 1, 'spacecharacter' => '-' ), 'languagegetvar' => 'l', 'languageexceptionuids' => '', 'languagefield' => 'sys_language_uid', 'transorigpointerfield' => 'l10n_parent', //'autoupdate' => 1, //'expiredays' => 180, ) ), ), '3' => 'productsdbconfiguration', // ext: productsdb end
),
so, here question: there way , need do, skip optional path segment, if empty?
thanks in advance having @ it.
here's code used realurl encodespurl_postproc hook:
public function encodeurl(&$params) { $originalparameters = $params['pobj']->getoriginalurlparameters(); if(array_key_exists('tx_productsdb_categories[category]', $originalparameters)===true) { if (strpos($params['url'], '//')) { $encodedsegments = explode('/', $params['url']); $modifiedsegments = array_filter($encodedsegments, 'strlen'); $params['url'] = implode('/', $modifiedsegments); } } }
let me know, if got other ideas improvement.
Comments
Post a Comment