query with if in cake php 2 - if-statement

I'm trying to get data with an if in Cakephp version 2
$this->Zona->find( 'list', array( 'fields' => array('nombre', 'IF(tiempo_hombre=0, tiempo_mujer, tiempo_hombre ')
but I get an error

Related

Gravity forms repeater with upload file error

I'm building a form with a repeater and a file upload inside. When I submit the form, the input file filed always give me the error: There was an error while uploading the file. Error code: 1
Add
Here's my code:
$uploadfiles = GF_Fields::create( array(
'type' => 'fileupload',
'id' => 1006, // The Field ID must be unique on the form
'formId' => $form['id'],
'multipleFiles' => false,
'allowedExtensions' => 'gif,jpg,jpeg,png,txt,rtf,pdf,doc,docx,odt,ppt,pptx,odp,xls,xlsx,ods,xml',
'description' => '<br>Relevant documents: our transport way bill, probill, photos, etc.<br>Files must be less than 2 MB.<br>Allowed extensions: gif jpg jpeg png txt rtf pdf doc docx odt ppt pptx odp xls xlsx ods xml.',
'label' => __('Please attach any relevant document', 'srx'),
'pageNumber' => 1, // Ensure this is correct
));
// Create a repeater for the team members and add the name and email fields as the fields to display inside the repeater.
$team = GF_Fields::create( array(
'type' => 'repeater',
'description' => '',
'id' => 1000, // The Field ID must be unique on the form
'formId' => $form['id'],
'label' => __('Products', 'srx'),
'addButtonText' => __('Add product', 'srx'),
'removeButtonText' => __('Remove product', 'srx'),
'maxItems' => 100, // Optional
'pageNumber' => 1, // Ensure this is correct
'fields' => array( $reference, $quantity, $product, $lista, $uploadfiles ), // Add the fields here.
) );
Even tho the field is not required, it gives me the error anyways.
Another question I have is about the use of multipleFiles = true. This doesn't work at all. Any idea why ?
Thank you so much !
The Repeater API does not currently support File Upload fields. Here's a full list of known limitations:
https://docs.gravityforms.com/repeater-fields/#limitations
If you need repeating file uploads, check out Gravity Forms Nested Forms:
https://gravitywiz.com/documentation/gravity-forms-nested-forms/

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

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.

CakePHP - Router::url doesn't build pretty URLs when there's a regex match in the Router::connect

In my CakePHP, my routes.php file looks like this:
Router::connect('/premios/:category',
array('controller' => 'prizes', 'action' => 'category'),
array(
'category' => '\bmarcas|restaurantes|combustibles|peluqueria\b',
));
This way whenever a user enters the /premios url, the next parameter is matched with the "category" regex. This works perfect.
The problem is that when I want to generate a pretty url for the category, let's say, "peluqueria", using this line of code generates a "non-pretty" url:
Router::url(array('controller' => 'prizes', 'action' => 'category', 'peluqueria')); ?>
Instead of generating a pretty URL (/premios/peluqueria) it generates a non pretty url (/prizes/category/peluqueria).
What am I doing wrong? Or is this a limitation of the Router::url function?
A workaround would be to define every connect, avoiding the regex, but it isn't a pretty as the current solution plus it would get annoying when the categories count start to grow.
Any ideas?
You have to actually name the category parameter in Router::url, like this
Router::url(array('controller' => 'prizes',
'action' => 'category',
'category' => 'peluqueria'));
And you'd probably want to pass that "category" parameter to the category action in Prizes, so you're missing something
Router::connect(
'/premios/:category',
array('controller' => 'prizes', 'action' => 'category'),
array(
'pass' => array('category'),
'category' => '\bmarcas|restaurantes|combustibles|peluqueria\b'
)
);
Look this part of the docs with more detention :)

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.