I have an extension for items, each has several fields. One field is name and one field is country.
In realurl_conf.php i can create a url like:
detail/name-1
with:
name' => array(
array(
'GETvar' => 'tx_myext_myplugin[model]',
'lookUpTable' => array(
'table' => 'tx_myext_domain_model_model',
'id_field' => 'uid',
'alias_field' => 'name',
'addWhereClause' => ' AND NOT deleted',
'useUniqueCache' => 1,
'useUniqueCache_conf' => array(
'strtolower' => 1,
'spaceCharacter' => '-',
),
),
),
But what if i also want to have the country in the url, like:
detail/country-xy/name-1
How can i achieve this?
Realurl can only map arguments which are available. Therefore you must also provide the country to the typolink generation.
Related
I have problems with my RealURL Configuration and can't find a solution. I have included banners in my site, but on the news detail pages the link does not work, creating a 403 error. So there has to be something wrong with my RealURL configuration:
'fixedPostVars' => array(
'newsDetailConfiguration' => array(
array(
'GETvar' => 'tx_news_pi1[news]',
'lookUpTable' => array(
'table' => 'tx_news_domain_model_news',
'id_field' => 'uid',
'alias_field' => 'title',
'addWhereClause' => ' AND NOT deleted',
'useUniqueCache' => 1,
'useUniqueCache_conf' => array(
'strtolower' => 1,
'spaceCharacter' => '-'
),
'languageGetVar' => 'L',
'languageExceptionUids' => '',
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l10n_parent',
'autoUpdate' => 1,
'expireDays' => 180,
)
)
),
'18' => 'newsDetailConfiguration',
The link when clicking on the banner looks like this:
/detail/?type=9002&tx_sfbanners_pi1[banner]=4&tx_sfbanners_pi1[action]=click&tx_sfbanners_pi1[controller]=Banner&cHash=5ab32cd1edb0529752985d5e30dfd8be
Thanks for your help!
The parameters of EXT:news are missing and need to be added when you create the link of the banner
I try to change my generated url from http://www.example.com/page/extensionname/MyArticleNumber/ to http://www.example.com/page/MyArticleNumber/ using Realurl 1.12.8 and TYPO3 6.2.27.
My realurl_conf.php:
'postVarSets' => array(
'_DEFAULT' => array(
'extensionname' => array(
array(
'GETvar' => 'extensionname_plugin[article]',
'lookUpTable' => array(
'table' => 'tx_extensionname_domain_model_article',
'id_field' => 'uid',
'alias_field' => 'CONCAT(short_title, \'-\', juq)',
'addWhereClause' => ' AND NOT deleted',
'useUniqueCache' => 1,
'useUniqueCache_conf' => array(
'spaceCharacter' => '-',
),
),
),
),
),
What and and where do I have to edit to solve this problem?
Thank you in advance.
If you use your extension at one specific page you can use 'fixedPostVars'
'fixedPostVars' => array(
# extension configuration
'extensionname' => array(
array(
'GETvar' => 'extensionname_plugin[article]',
'lookUpTable' => array(
'table' => 'tx_extensionname_domain_model_article',
'id_field' => 'uid',
'alias_field' => 'CONCAT(short_title, \'-\', juq)',
'addWhereClause' => ' AND NOT deleted',
'useUniqueCache' => 1,
'useUniqueCache_conf' => array(
'spaceCharacter' => '-',
),
),
),
),
# PID for extension configurations
'99' => 'extensionname',
),
I have make use of the encodeSpURL_postProc and decodeSpURL_preProc functions of realUrl.
The following code have I added to my realurl_conf.php file:
<?php
$GLOBALS['realURLEncodeSpURLArray'] = array(
'url/by/realurl/' => 'new/url/',
'page/extensionname/' => 'page/'
);
function user_encodeSpURL_postProc(&$params, &$ref)
{
$params['URL'] = str_replace(array_keys($GLOBALS['realURLEncodeSpURLArray']), array_values($GLOBALS['realURLEncodeSpURLArray']), $params['URL']);
}
function user_decodeSpURL_preProc(&$params, &$ref)
{
$params['URL'] = str_replace(array_values($GLOBALS['realURLEncodeSpURLArray']), array_keys($GLOBALS['realURLEncodeSpURLArray']), $params['URL']);
}
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl'] = array(
'encodeSpURL_postProc' => array('user_encodeSpURL_postProc'),
'decodeSpURL_preProc' => array('user_decodeSpURL_preProc'),
'_DEFAULT' => array(
...
);
Please ensure that the new/url/should be unique so that there is no conflict.
By example: If you want to map txnews you got an url like mynewspage/details/txnews/article you should replace mynewspage/details/txnews/ with mynewspage/details/. Do not replace txnews/ with /!
You must get a reference to the type:
http://site.ru/agencies/town/name_agencies.
Here is an example of code that is at the moment:
'fixedPostVars' => array(
'71' => array (
array (
'GETvar' => 'tx_extention_pi1[town_id]',
'lookUpTable' => array(
'table' => 'tx_extention_table',
'id_field' => 'uid',
'alias_field' => 'town_name',
'addWhereClause' => ' AND NOT deleted',
'useUniqueCache' => 1,
'useUniqueCache_conf' => array(
'strtolower' => 1,
'spaceCharacter' => '-',
),
),
),
array (
'GETvar' => 'tx_extention_pi1[uid]',
'lookUpTable' => array(
'table' => 'tx_extention_table2',
'id_field' => 'uid',
'alias_field' => 'IFNULL(NULLIF(pathsegment,""), agency_title)',
'addWhereClause' => ' AND NOT deleted',
'useUniqueCache' => 1,
'useUniqueCache_conf' => array(
'strtolower' => 1,
'spaceCharacter' => '-',
),
),
),
),
),
The result of his work is correct, but taking into account the fact that town_id always determined.
If town_id not established a link have the form:
site.ru/agencies//name_agencies
And the need for such a case:
site.ru/agencies/name_agencies
Use 'noMatch' => 'bypass' makes no sense, since it is intended to 'valueMap' => array (). A 'valueDefault' => 'string' only specifies the default option, unless otherwise provided.
Is there any option that is designed to 'lookUpTable' => array (), but to work as a 'noMatch' => 'bypass'?
I.e. to move to the next segment if the current is not defined.
When I got multiple values in my URL of the same name
e.g …&tx_myext_pi1[crit][]=1&tx_myext_pi1[crit][]=2…
and I want to have it multiple times in my RealUrl-ified URL
like …/crit/title-of-crit-1/crit/title-of-crit-2…
it's not working.
I only get …/crit/title-of-crit-1… and …/crit/title-of-crit-2… is missing
…&tx_myext_pi1[crit][]=1…
translates to …/crit/title-of-crit-1/… and
…&tx_myext_pi1[crit][]=2…
translates to …/crit/title-of-crit-2/…
so that part is working. But not multiple values.
Is this impossible to do with RealUrl?
Should I make a userFunc? How?
My RealUrl Conf
// …
'postVarSets' => array(
'_DEFAULT' => array(
'crit' => array(
array(
'GETvar' => 'tx_myext_pi1[crit][]',
'lookUpTable' => array(
'table' => 'tx_myext_domain_model_crit',
'id_field' => 'uid',
'alias_field' => 'title',
'languageGetVar' => 'L',
'languageExceptionUids' => '',
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l10n_parent',
'autoUpdate' => 1,
),
),
),
),
// …
Is this impossible to do with RealUrl?
Yes, is impossible to achieve this using RealUrl.
The problem is that you are using array in the query string.
You can merge your values in one string
Like this:
/crit/title-of-crit-1,title-of-crit-1
Or
/crit/title-of-crit-1+title-of-crit-1
And split it when you need. by , Or + or another special character.
For example Drupal uses this rule for multiple values in views moudle.
I have an URL which looks like this:
http://domain.com/leistungen/industrial-design/?tx_fsproject_fsprojectfp%5Bproject%5D=2&tx_fsproject_fsprojectfp%5Baction%5D=show&tx_fsproject_fsprojectfp%5Bcontroller%5D=Project&cHash=7c405bcde49853af9a7e78bdf465002c
Using RealURL with the following configuration (and some hook functions as explained here):
'postVarSets' => array(
'_DEFAULT' => array(
// projects
'industrial-design' => array(
array(
'GETvar' => 'tx_fsproject_fsprojectfp[controller]',
),
array(
'GETvar' => 'tx_fsproject_fsprojectfp[action]',
),
array(
'GETvar' => 'tx_fsproject_fsprojectfp[project]',
'lookUpTable' => array(
'table' => 'tx_fsproject_domain_model_project',
'id_field' => 'uid',
'alias_field' => 'title',
'addWhereClause' => ' AND deleted !=1 AND hidden !=1',
'useUniqueCache' => 1,
'useUniqueCache_conf' => array(
'strtolower' => 1,
'spaceCharacter' => '-',
)
)
),
),
),
),
I get an URL looking like this:
http://domain.com/leistungen/industrial-design/industrial-design/projekt/project-b/
This is not bad. However, why does the industrial-design/ part show up twice?
The first industrial-design is the page that is being displayed. The second one is the keyword inserted by RealURL to identify the set of variables. To avoid that you can:
Change the structure of pages so that you don't have industrial-design page at all.
Rename the postVarSets that you set up in the RealURL configuration.
Use fixedPostVars instead as that doesn't use a keyword to identify the set of variables but a page UID.