Rewrite default language URL - redirect

I just have setup a typo3 website. Page is running well. But got some error. My Onpage optimization everytime gives me a bad feedback because of the default language tag.
www.mywebsite.com/contact/
and
www.mywebsite.com/contact/?L=0
When I try to redirect it well, with a permanent moved 301 redirect, it creates a loop and I canĀ“t redirect his well.
I tried to redirect it with my_redirects extension and also with htacess, but I got just a bad result.

Lets say your default language is en and your secondary language is es then try this snippet in your <typo3root>/typoconf/realurl_conf.php.
'preVars' => array (
0 => array (
'GETvar' => 'L',
'valueMap' => array (
'es' => '1',
),
'noMatch' => 'bypass',
),
),
I think your missing the 'noMatch' => 'bypass', it allows the L parameter to be absent.
This will result in:
English / default URL: www.mywebsite.com/contact/
Spanish URL: www.mywebsite.com/es/contacto/

Related

changing TYPO3 realurl language urls

I'm using TYPO3 7.6.11 and realurl 2.0.15
my translated versions got this url:
http://url.de/3/services
is there a way to replace the 3 with the language code? for 3 it should be en for example?
thanks a lot
You need to add the 'preVars' configuration array for your languages to realurl.
It is straigtly described in the manual:
Realurl manual - language example config deep-link
Excerpt/Example:
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF'] ['realurl'] ['_DEFAULT'] ['preVars'] => array(
array(
'GETvar' => 'L',
'valueMap' => array(
'de' => '0',
'en' => '1',
),
'valueDefault' => 'de',
# 'noMatch' => 'bypass',
),
);
Alternatively you could just use the 'automatic configuration' shipped with realurl. AFAIR it usually adds also lang-configs.
The Auto-Conf feature is to be enabled via Extension-Manager.
Please, see how to set up languages correctly: https://github.com/dmitryd/typo3-realurl/wiki/Notes-for-Integrators#configuring-languages There are instructions and examples there.

How to add custom wizards in typo3 7 TCA?

When I try to add the wizard named wizard_geo_selector in TCA ,there arised an error "module not registered".Please tell me how to register the wizard properly in the TCA.?
In TYPO3 Version 7.6 new wizards are added like this:
Inside your extension create the directory Configuration/Backend/
In the new directory create a file Routes.php, it will be found automatically, no mentioning in ext_localconf.php or ext_tables.php is required. If you still need Ajax you can add the file AjaxRoutes.php in the same folder.
Content for Routes.php:
return array(
'my_wizard_element' => array(
'path' => '/wizard/tx_geoselecotor/geo_selector_wizard',
'target' => \Path\To\your\class\WizardGeoSelector::class . '::WizardAction'
),
);
Content for AjaxRoutes.php
<?php
/**
* Definitions for routes provided by EXT:backend
* Contains all AJAX-based routes for entry points
*
* Currently the "access" property is only used so no token creation + validation is made
* but will be extended further.
*/
return array('my_ajax_element' => array(
'path' => 'tx_geoselecotor/my_ajax_route',
'target' => \Path\To\your\class\MyAjaxController::class .'::myAjaxFunction'
));
If you're unsure about the notation you can compare with existing entries in the Global Variables in the Backend:
Navigate to System -> Configuration -> Backend Routes
The route of the paths is handled different, for Ajax it's always "ajax" prepended, so you've never to add it to the path, else it's twice in the route. For the common route there is no change concerning the defined string.
Now the wizard can be used and even it never has to be defined in ext_tables.php it has to be mentioned there from any table-field in the configuration-area (module[name]):
'table_field_for_wizard' => array(
'label' => 'LLL:EXT:my_extension/Resources/Private/Language/locallang.xml:table_name.tx_myextension_wizard',
'config' => array (
'type' => 'user',
'userFunc' => 'Path/to/class/without/wizard->renderForm',
'wizards' => array(
'my_wizard' => array(
'type' => 'popup',
'title' => 'MyTitle',
'JSopenParams' => 'height=700,width=780,status=0,menubar=0,scrollbars=1',
'icon' => 'EXT:' . $_EXTKEY . '/Resources/Public/img/link_popup.gif',
'module' => array(
'name' => 'my_wizard_element',
'urlParameters' => array(
'mode' => 'wizard',
'ajax' => '0',
'any' => '... parameters you need'
),
),
),
'_VALIGN' => 'middle',
'_PADDING' => '4',
),
# Optional
#'softref'=>'something',
),
),
In the userFunc Path/to/class/without/wizard->renderForm you've to create a button which is linking to the wizard and onClick the wizard will open with the route you defined in Routes.php and the optional urlParameters.
Currently I never found this whole item explained in the core-documentation.
Edit:
Details about routing can be found here: Routing
The rendering process can be found here: Rendering / NodeFactory
You should probably read also the outer context of the linked paragraph.
Edit 2:
An example extension can be found here, some things never work 100% but the wizard is working. The extension is for TYPO3 Version 7:
https://github.com/DavidBruchmann/imagemap_wizard
Ricky's answer doesn't really work anymore, since addModulePath ist deprecated since version 7.
Also, just registering the module like this still give's you said error.
The only thing that keeps the wizard going again is this:
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addModule('wizard','pbsurvey_answers',"",\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY).'wizard/');
But when you add this, the module appears as a new point in your TYPO3 backend.
IN TCA add the wizard like follows:
'module' => array(
'name' => 'wizard_geo_selector',
),
In ext_tables.php register the wizard.
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addModulePath(
'wizard_geo_selector',
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'Modules/Wizards/Yourwizardname/'
);
Keep in mind this is deprecated since Typo3 7 and removed in Typo3 8.So you can use this method upto Typo3 7.For Typo3 8 do use the method specified by David below.

How to end typo3 realurl with .html

I'm using the realurl extension to make nice urls, only they all end with the / char. How can I let them end like a .html file?
/path/to/page/
Would like to have:
/path/to/page.html
In your realurl configuration file (usually typo3conf/realurl_conf.php1) there is a section fileName. In it there is a key defaultToHTMLsuffixOnPrev. Set it's value to 1. Should look somehow like this afterwards (generated by realurl autoconfig):
'fileName' =>
array(
'defaultToHTMLsuffixOnPrev' => 1, // <-- Important part
'acceptHTMLsuffix' => 1,
'index' =>
array(
'print' =>
array(
'keyValues' =>
array(
'type' => 98,
),
),
),
),
1 If you used realurl autoconfiguration, the configuration file is generated to realurl_autoconf.php. Make sure to set the auto configuration format to plain PHP-code in the realurl-settings in the extension manager, then delete typo3conf/realurl_autoconf.php to trigger regeneration, and copy the regenerated file to typo3conf/realurl_conf.php.

wordpress WP Query and Custom Field filtering

I've encoutered problem with filtering pages to display in WP query.
I use Codex WP query reference for custom fields with ACF (Advanced Custom Fields plugin - but it doesn't matter, couse it works same as WP custom field) parameters to filter pages.
In "Multiple Custom Field Handling" paragraph, Codex got an example with 2 conditions. We can use OR or AND relation. I works for both until you have 3rd condition (array).
They use example:
'relation' => 'OR',
array(
'key' => 'color',
'value' => 'blue',
'compare' => 'NOT LIKE'
),
array(
'key' => 'price',
'value' => array( 20, 100 ),
'type' => 'numeric',
'compare' => 'BETWEEN'
)
It has only 2 arrays. When I put 3rd, nothing shows. In debug mode I can see an error:
WordPress database error: [Lost connection to MySQL server during query]
When I use AND it works, but I got to use OR. Unfortunately it makes MySQL disconnect.
I've tryed asking phpMySQL for same query WP does. It couses problem - phpMyAdmin says same:
Lost connection
Any Idea?
Maybe I should try different aproach for filtering? (maybe I should use taxonomy?)
Here is code I use:
$query_array = array('relation' => 'OR');
array_push($query_array,
array(
'key' => 'filter1',
'value' => 'value1',
'compare' => 'LIKE'
),
array(
'key' => 'filter1',
'value' => 'value2',
'compare' => 'LIKE'
),
array(
'key' => 'filter1',
'value' => 'value3',
'compare' => 'LIKE'
)
);
$args = array(
'order' => $order_array,
'meta_key' => $meta_key,
'orderby' => $orderby,
'post_type' => 'page',
'paged' => $paged,
'post__in' => $postIDs,
'posts_per_page' => 12,
'paged' => get_query_var('paged'),
'meta_query' => $query_array
);
query_posts($args);
?>
(variables for $args are set of course)
I don't know why I can't use
'compare' => '='
but probably it is why I can't use:
$query_array = array('relation' => 'OR');
array_push($query_array,
array(
'key' => 'filter1',
'value' => array('value1', 'value2', 'value3'),
'compare' => 'IN'
)
);
Just wanted to say that your comment helped me; I'd been butting my head against a very similar problem for a while. I'm using ACF too, and using it to attach items of one post type to another custom post type was easy - for instance, to Attach Person_1 and Person_3 to "Project_A".
This made it easy to list out which users were attached to specific projects. But when it came to do the same in reverse - to show which projects were attached to which users - it became a massive headache.
I finally figured it out, in part thanks to your comment - I'll post my solution here in case someone else comes along with the same problem:
$args = array(
'numberposts' => -1,
'post_type' => 'project',
'meta_query' => array(
'relation' => 'IN',
array(
'key' => 'people',
'value' => ';s:1:"' . $person->ID . '";',
'compare' => 'LIKE'
)
)
);
In short: because the ACF values in repeater fields et cetera are serialized, the compare keyword has to be "LIKE", and I added some context to the value to eliminate false returns - just searching for an ID like "1" would match a lot of the (wrong) posts, but the ";s1;" part ensures that the given value is at index 1, which in my case is the correct index.
So it would need tweaking from case to case. Inspecting what you're trying to match up with var_dumping "get_post_meta($post->ID, 'people')" is helpful for getting the value correct.

TYPO3 realurl removes GET values

I need help =/
I updated TYPO3 to 4.5.5 and an older Version of realurl.
The plugin we're using gets the GET parameters by reading the 't3lib_div::_GET();' variable.. realurl does not let through values that are submited by the original GET method, it only passes the "readable" url parameters....
so:
www.anypage.com/welcome/any
works with config:
array(
'GETvar' => 'tx_plugin_pi1[database]',
'valueMap' => array(
'one' => 'one',
'any' => 'any'
),
'noMatch' => 'bypass'
)
but:
www.anypage.com/welcome/?database=any
does not pass the value ('any') to the plugin...
I second Koopa's answer.
In addition to that the variable must include the prefix:
www.anypage.com/welcome/?tx_plugin_pi1[database]=any
or you update the real url config to:
array(
'GETvar' => 'database',
'valueMap' => array(
'one' => 'one',
'any' => 'any'
),
'noMatch' => 'bypass'
)
The variable should always be accessible through $this->piVars['database'], is it not?