Conversion from realurl to routeEnhancers in TYPO3 9... Adapt LookUpTables with additional ValueMaps or how to define the "zero-value-segment"? - realurl

I am upgrading a project about training courses and my URL-segments are like:
/category/course/location.html
Got it running with the following configuration:
routeEnhancers:
PageTypeSuffix:
type: PageType
default: '.html'
map:
'.html': 0
CoursePlugin:
type: Extbase
limitToPages:
- 1
- 15
- 17
- 18
extension: Course
plugin: Catlist
namespace: course_catlist
routes:
- routePath: '/{category_title}/{course_title}/{location_title}'
_controller: 'Category::list'
_arguments: {category_title: 'category', course_title: 'course', location_title: 'location'}
defaultController: 'Category::list'
aspects:
category_title:
type: PersistedAliasMapper
tableName: tx_course_domain_model_category
routeFieldName: 'slug'
course_title:
type: PersistedAliasMapper
tableName: tx_course_domain_model_course
routeFieldName: 'slug'
location_title:
type: StaticValueMapper
map:
alle-standorte: 0
hamburg: 1
berlin: 2
The problem is now: It's only working if there are values for all 3 parameters set! But for example there could be a segment like
/language-courses/all-courses/berlin.html
The course-parameter is empty, so all "language-courses" in "berlin" are shown in a list.
In realurl it is possible to combine a lookUpTable with a valueMap!
array(
'GETvar' => 'tx_course_catlist[course]',
'valueMap' => array(
'all-courses' => "",
),
'lookUpTable' => array(
'table' => 'tx_course_domain_model_course',
'id_field' => 'uid',
'alias_field' => 'title',
'addWhereClause' => ' AND deleted=0 ',
'useUniqueCache' => 1,
'useUniqueCache_conf' => array(
'strtolower' => 1,
'spaceCharacter' => '-',
),
),
)
How can I adapt this in TYPO3 9? Any experience or ideas? How can I map an empty-value for a segment of a PersistedAliasMapper?

Found a solution:
Create a record with an uid=0 in the database. Call the path-segment-field for example like "all-courses".
This has an unpleasant side effect that the record appears in the TYPO3 backend and if you want to edit it, you get an error message that the UID must not be 0. So just do it via PHPmyadmin...
And you have to make sure that the value passed to course is not NULL but "0" when building the URL.

Related

Oracle APEX ORDS Limitation on URL template?

Is there a limitation on the Oracle APEX ords template?
Currently mapping a GET Request to
Works : URI Template: /history/{PLATAFORM}/{CONTEXT}/{APPLICAT}/
Works : URI Template: /history/{PLATAFORM}/{CONTEXT}/{APPLICAT}/test/
405 Method Not Allowed: URI Template: /history/{PLATAFORM}/{CONTEXT}/{APPLICAT}/{test}/
Can't find documentation about this scenario, wonder if it's Oracle APEX limitation/Bug? Or Maybe some configuration somewhere?
Any help would be appreciated,
Regards.
No limitations other than please switch to using : syntax over {}. We changed that a while back.
-- Generated by Oracle SQL Developer REST Data Services 18.1.0.051.1417
-- Exported REST Definitions from ORDS Schema Version 17.4.0.18.13.50
-- Schema: KLRICE Date: Tue Apr 03 15:03:00 EDT 2018
--
BEGIN
ORDS.ENABLE_SCHEMA(
p_enabled => TRUE,
p_schema => 'KLRICE',
p_url_mapping_type => 'BASE_PATH',
p_url_mapping_pattern => 'klrice',
p_auto_rest_auth => FALSE);
ORDS.DEFINE_MODULE(
p_module_name => '/history/',
p_base_path => '/history/',
p_items_per_page => 25,
p_status => 'PUBLISHED',
p_comments => NULL);
ORDS.DEFINE_TEMPLATE(
p_module_name => '/history/',
p_pattern => ':PLATFORM/:CONTEXT/:APPLICAT/test',
p_priority => 0,
p_etag_type => 'HASH',
p_etag_query => NULL,
p_comments => NULL);
ORDS.DEFINE_HANDLER(
p_module_name => '/history/',
p_pattern => ':PLATFORM/:CONTEXT/:APPLICAT/test',
p_method => 'GET',
p_source_type => 'json/collection',
p_items_per_page => 25,
p_mimes_allowed => '',
p_comments => NULL,
p_source =>
'select :PLATFORM,:CONTEXT,:APPLICAT from dual'
);
COMMIT;
END;

Creating Salesorder with Vtiger Webservice missing Tax

I have the Problem when creating an salesorder with Vtiger Webservice,
The sales order is created but somehow the tax is not added.
I thought it has something to do with the parameter : hdnTaxType
Cause even if I add this value 'group' it does not apply the Tax to the Salesorder.
I have to manually add The Taxtype 'group' then the system adds the tax.
thats why i tried to add values like:
'tax1' => '7.00',
and
'group_tax' =>[
'group_tax_percentage1' => '7.0'
],
nothing so far did help...
has anybody an Idea what the problem is?
Thank you
Tobi
$salesOrder =[
'lastname' => $customer['lastname'],
'subject' => 'Order from 01.01.1018',
'sostatus' => '1',
'assigned_user_id' => '',
'bill_street' => 'Rechunngsstrasse 123',
'ship_street' =>'Lieferungsstrasse 123',
'productid' => '14x4325',
'currency_id' => '21x1',
'carrier' => 'DHL',
'txtAdjustment' => '13',
'salescommission' => '12',
'exciseduty' => '15',
'hdnTaxType' => 'group',
'tax1' => '7.00',
'hdnS_H_Amount' => '22.22',
'group_tax' =>[
'group_tax_percentage1' => '7.0'
],
'LineItems' => [
0 => [
"taxid" => "33x1",
'productid'=>'14x6',
'listprice'=>'20.53',
'quantity'=>'3',
'comment' => "Product123"
]
]
Webservices in Vtiger are not complete.
In this case you can register your own webservice that makes your queries, or check the SalesOrder in the after-save event

Regex Routing - my rule is not found

I'm quite a beginner with Zend Framework so I would much appreciate your help to understand why my regex routing rule is not found.
Here is the rule:
// Picture: www.mywebsite.com/gallery/12/pic/45/my-beautiful-picture.html
$router->addRoute('picture',
new Zend_Controller_Router_Route_Regex(
'gallery/(\d+)/pic/(\d+)/([A-Za-z0-9.]+)',
array(
'module'=>'frontoffice',
'controller'=>'gallery',
'action'=>'picture'
),
array(
1 => 'gallery_id',
2 => 'picture_id',
3 => 'title'
),
'gallery/%d/pic/%d/%s'
)
);
When I visit the page www.mywebsite.com/gallery/1/pic/9/my-beautiful-picture.html I get this error message:
An error occurred
Page not found
Exception information:
Message: Action "1" does not exist and was not trapped in __call()
Stack trace:
#0 /usr/local/zend/share/ZendFramework/library/Zend/Controller/Action.php(518): Zend_Controller_Action->__call('1Action', Array)
#1 /usr/local/zend/share/ZendFramework/library/Zend/Controller/Dispatcher/Standard.php(295): Zend_Controller_Action->dispatch('1Action')
#2 /usr/local/zend/share/ZendFramework/library/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#3 /usr/local/zend/share/ZendFramework/library/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch()
#4 /usr/local/zend/share/ZendFramework/library/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#5 /var/www/misterjules/public/index.php(27): Zend_Application->run()
#6 {main}
Request Parameters:
array (
'controller' => 'gallery',
'action' => '1',
'pic' => '9',
'module' => 'frontoffice',
)
My other Regex Routing rules (written before in the script) which work fine are as follows:
// *** GALLERY ***
// Galleries (index): www.mywebsite.com/gallery
$router->addRoute('galleries',
new Zend_Controller_Router_Route_Regex(
'gallery(/page=(\d+))?',
array(
'module'=>'frontoffice',
'controller'=>'gallery',
'action'=>'galleries'
),
array(
2 => 'page',
),
'gallery'
)
);
// a gallery index: www.mywebsite.com/gallery/13/my-travel-in-dublin.html
// OR www.mywebsite.com/gallery/13/my-travel-in-dublin.html/page=4
$router->addRoute('gallery',
new Zend_Controller_Router_Route_Regex(
'gallery/(\d+)/([A-Za-z0-9.]+)(/page=(\d+))?',
array(
'module'=>'frontoffice',
'controller'=>'gallery',
'action'=>'gallery'
),
array(
1 => 'gallery_id',
2 => 'title',
4 => 'page'
),
'gallery/%d/%s'
)
);
I don't understand where my mistake is.
Thanks for your help.
Jules
It appears that your regex is missing a dash which it needs in order to match gallery/12/pic/45/my-beautiful-picture.html.
Try this:
$router->addRoute('picture',
new Zend_Controller_Router_Route_Regex(
'gallery/(\d+)/pic/(\d+)/([A-Za-z0-9.-]+)', #etc.

ZF routing - url with extension with Nth params

Similar to this question, I have accomplished passing the format with the url extension, but you have have to declare the parameters passed upfront. Example:
new Zend_Controller_Router_Route_Regex(
'([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)(\.(\w+))?',
array(
'module' => 'Default',
'controller' => 'index',
'action' => 'index',
),
array(
1 => 'module',
2 => 'controller',
3 => 'action',
4 => 'extension',
5 => 'format'
)
);
But what if I want /:module/:controller/:action/*.:format???
So that no matter how many parameters I pass through the url, the '.whatever' will be the format parameter? Basically, I'm trying to take the default router and add extension as the 'format param'.
Edit:
The issue isn't grabbing the extension, the issue is adding other params. For example
/blogs/posts/view/post/500/foo/bar/format/html
will translate into:
array('module'=>'blogs','controller'=>'posts', 'action' => 'view', 'post'=>500, 'format' => 'html', 'foo' => 'bar');
But I want to be able to represent the format the same route like so:
/blogs/post/view/post/500/foo/bar.html
No matter how many parameters are declared between the action and the format.
Your whatever you can specify with .* expression.
To match it - simply: (.*)
If you want not to grab for example extension, use ?:
(.*?)(\.(\w+))

Zend Framework - Router Rewrite with Regex

I have been trying to shortern this route:
http://abc.localhost/user/view/index/id/1
to this:
http://abc.localhost/user/1
with the following portion of code in my bootstrap but I keep getting an error stating that the 'Reversed route is not specified', any ideas why?
$route = new Zend_Controller_Router_Route_Regex(
'user/(\d+)',
array(
'module' => 'user',
'controller' => 'view',
'action' => 'index'
),
array(
1 => 'id'
)
);
$router->addRoute('user', $route);
Thanks,
Martin
If you want to use the URL helper with Regex routes you need to pass a 4th parameter to Zend_Controller_Router_Route_Regex that it can use to rebuild the route. This 4th parameter should be a string in a sprintf-format which it can inject the params into.
In your case it would be something like:
$route = new Zend_Controller_Router_Route_Regex(
'user/(\d+)',
array(
'module' => 'user',
'controller' => 'view',
'action' => 'index'
),
array(
1 => 'id'
),
'user/%d'
);
$router->addRoute('user', $route);
There is some info on this right at the end of the manual section on Regex routes: http://framework.zend.com/manual/en/zend.controller.router.html#zend.controller.router.routes.regex - but it's easy to miss.