# |
Jun 14th 2021, 12:12 |
slackebot |
$builder) { $builder->connect('/', ['controller' => 'cv', 'action' => 'index']); $builder->connect('/:language/:controller/:action/*', array(), array('language' => 'en|ar')); $builder->connect('/:language/:controller', array('action' => 'index'), array('language' => 'en|ar')); $builder->connect('/:language', array('controller' => 'cv', 'action' => 'index'), array('language' => 'en|ar')) ; |
# |
Jun 14th 2021, 12:12 |
slackebot |
time getting error saying missing route, while sometime ```Warning (2): preg_match(): Compilation failed: two named subpatterns have the same name (PCRE2_DUPNAMES not set) at offset 42 [CORE\src\Routing\Route\Route.php, line 454]``` my routes are as below ```<?php use Cake\Routing\Route\DashedRoute; use Cake\Routing\RouteBuilder; $routes->setRouteClass(DashedRoute::class); $routes->scope('/:language', function (RouteBuilder |
# |
Jun 14th 2021, 12:12 |
alamnaryab |
I have cakephp4.2 project I have admin prefix I am using Authentication Plugin for admin I also have Localization that is English and Arabic Languages, it worked until the language parameter is saved in session (followed official documentation) but when I needed to show language parameters in URLs and also `$this->Html->link()` automatically add current language parameters to links I tried many things with routing, some |
# |
Jun 14th 2021, 12:02 |
alamnaryab |
ok let me write again with more description |
# |
Jun 14th 2021, 11:56 |
a.vanniel |
I fear that is because it is not clear what your question is... or at least I did not even see anything remotely like a question until i clicked on the reply of your own message. |
# |
Jun 14th 2021, 11:45 |
alamnaryab |
:white_frowning_face: no one is helping me |
# |
Jun 14th 2021, 11:43 |
alamnaryab |
tried many things some time getting missing route some time some other error |
# |
Jun 14th 2021, 11:41 |
dantedantas |
Thanks @kevin.pfeifer. I am new to CakePHP and I didn't have time to improve my knowledge with CakePHP. I will give it a try. If I will have questions, I will come back here to "bother" you. :) Vielen Dank! |
# |
Jun 14th 2021, 11:41 |
slackebot |
$routes ->connect('/:controller/:action/*', []) ->setPatterns($patterns); $routes ->connect('/:controller', ['action' => 'index']) ->setPatterns($patterns); $routes ->connect('/', ['controller' => 'Users', 'action' => 'login']) ->setPatterns($patterns); $routes->fallbacks(DashedRoute::class); }); });``` |
# |
Jun 14th 2021, 11:41 |
slackebot |
$builder->connect('/:language/:controller', array('action' => 'index'), array('language' => 'en|ar')); $builder->connect('/:language', array('controller' => 'cv', 'action' => 'index'), array('language' => 'en|ar')) ; $builder->fallbacks(); }); $routes->scope('/:language', function (RouteBuilder $routes) { $routes->prefix('Admin', function (RouteBuilder $routes) { $patterns = ['language' => 'en|ar']; |
# |
Jun 14th 2021, 11:41 |
alamnaryab |
Cakephp4 Routing with language parameter and admin prefix ```<?php use Cake\Routing\Route\DashedRoute; use Cake\Routing\RouteBuilder; $routes->setRouteClass(DashedRoute::class); $routes->scope('/', function (RouteBuilder $builder) { $builder->connect('/', ['controller' => 'cv', 'action' => 'index']); $builder->connect('/:language/:controller/:action/*', array(), array('language' => 'en|ar')); |
# |
Jun 14th 2021, 11:40 |
alamnaryab |
Cakephp4 Routing with language parameter and admin prefix |
# |
Jun 14th 2021, 11:35 |
kevin.pfeifer |
so if you add a function called `overview` inside any controller you can call that function via `/<controller-name>/overview |
# |
Jun 14th 2021, 11:32 |
kevin.pfeifer |
and the way controllers and its functions are named decides how they can be accessed in the URL see https://book.cakephp.org/4/en/intro/conventions.html |
# |
Jun 14th 2021, 11:32 |
kevin.pfeifer |
thats the public function above in my example |
# |
Jun 14th 2021, 11:31 |
kevin.pfeifer |
well basically a controller action is a function inside a controller :) |
# |
Jun 14th 2021, 11:31 |
dantedantas |
Thank you @kevin.pfeifer. Looks like a great idea. In that case, I only need to create a "controller action"? Maybe do you have a link/website with some kind of explanation on how to do that? Maybe an example? I will start with some tests here. Thank you again. |
# |
Jun 14th 2021, 11:14 |
slackebot |
'data' => $customers->contacts ] ) ); } }``` which you then can call via ```/customers/ajax-get-contacts/<ID>``` |
# |
Jun 14th 2021, 11:14 |
kevin.pfeifer |
e.g. ```// inside the src/Controller/CustomersController.php public function ajaxGetContacts( $id = null ): Response { $request = $this->getRequest(); $response = $this->getResponse(); if( $request->is( 'ajax' ) andand $request->is( 'get' ) ) { $customers = $this->Customers->get($id)->contain(['Contacts']); return $response->withType( 'application/json' ) ->withStringBody( json_encode( [ |
# |
Jun 14th 2021, 11:10 |
kevin.pfeifer |
@dantedantas instead of trying to re-invent the wheel by ourself and handle your AJAX request by ourself inside the webroot folder why not create a controller action which you call via AJAX? Then you are “in the environment” of CakePHP and don’t need to do the whole bootstrapping by ourself |
# |
Jun 14th 2021, 11:08 |
admad |
Bringing any over a decade old app upto would be a rewrite, unless maybe it's WP since it never progressed. |
# |
Jun 14th 2021, 11:05 |
admad |
Rewrite |
# |
Jun 14th 2021, 10:56 |
arthurb |
Morning gents, I have a new client thats running a CakePHP v1.3.21 application and his asking us to quote on upgrading it to v4. In your experience what will be the easiest, upgrade to V2 to V3 to V4 or rewrite from scratch? thanks :) |
# |
Jun 14th 2021, 10:56 |
slackebot |
*image* *1209×424 25 KB* Thank you for your attention and help. Link: https://discourse.cakephp.org/t/how-to-connect-db-from-webroots-folder/9436 |
# |
Jun 14th 2021, 10:56 |
dantedantas |
Dear All, please, could someone explain to me how could I from the folder webroot connect to the DB? I have tried without success: Or maybe I have another choice? So, what I am doing and why: I have a VIEW that is very slow because loads a lot of data. What I did is: I created a horizontal menu and when you click on the button I use AJAX to load the needed info. The files used with AJAX are located in webroot’s folder. |
# |
Jun 14th 2021, 10:54 |
dantedantas |
Servus! :) |
# |
Jun 14th 2021, 10:54 |
kevin.pfeifer |
servus :) |
# |
Jun 14th 2021, 10:53 |
dantedantas |
Hello from Wien. :) |
# |
Jun 14th 2021, 10:50 |
slackebot |
<kevin.pfeifer> |
# |
Jun 14th 2021, 10:49 |
kevin.pfeifer |
a .pot is just a template file from which you generate your .po files for your languages. If you want to have the same string in the msgid and the msgstr use the Software PoEdit, select all strings and go to Edit => “Copy from Source Text” |
# |
Jun 14th 2021, 10:46 |
Lac |
I actually do need it ^^ |
# |
Jun 14th 2021, 10:38 |
dereuromark |
so no need to do such a thing |
# |
Jun 14th 2021, 10:38 |
dereuromark |
exactly :) my point is that it is as expected once you actually use it |
# |
Jun 14th 2021, 10:31 |
Lac |
my msgstr is always empty |
# |
Jun 14th 2021, 10:30 |
dereuromark |
why is that needed? it is by default this when it is empty |
# |
Jun 14th 2021, 10:29 |
Lac |
Hey guys, does anyone know if there's are way to set the msgstr the same as the msgid when generating a pot file through the i18n extract ? Thanks ! |
# |
Jun 14th 2021, 10:10 |
y.teruyacookie |
Thank you for your reply. I’m sorry, I confirm that results of debug($reserves) and debug($cancels) are different. |
# |
Jun 14th 2021, 08:15 |
val |
What would be the correct way to destroy an instance of MyTable class in 3.x so that it would be removed from all places where it is referenced or cached? |
# |
Jun 14th 2021, 08:05 |
alamnaryab |
? |
# |
Jun 14th 2021, 07:13 |
alamnaryab |
would you be able to get my anydesk or teamviewer and debug if I am making any mistake? |
# |
Jun 14th 2021, 07:12 |
alamnaryab |
thank you for your time |