# |
Jun 22nd 2021, 18:05 |
kevin.pfeifer |
@madjid.gacem according to https://stackoverflow.com/questions/47717720/organize-models-in-subdirectories-cakephp-3 you would have to create your own TableLocator which contains that Subfolder. Instead I would highly recommend to split your code into a plugin instead of using subfolders |
# |
Jun 22nd 2021, 17:57 |
madjid.gacem |
Hi there, guys i've a CustomerTable into a separate folder with its own namespace, how can i get an instance of it using ```TableRegistry::getTableLocator()->get('Customers')``` ? |
# |
Jun 22nd 2021, 17:30 |
kevin.pfeifer |
I would create a custom finder method in the other model, call that in the controller where I need it and set the result as a separate array in the view. If they don’t actually have any connection at all, why should the data be accessed via an entity field? |
# |
Jun 22nd 2021, 17:20 |
kevin.pfeifer |
or use a svg :P |
# |
Jun 22nd 2021, 17:19 |
dereuromark |
time upgrade :P |
# |
Jun 22nd 2021, 17:18 |
kevin.pfeifer |
uh, fontaweomse 4.6.3 doesn’t have a discord icon… |
# |
Jun 22nd 2021, 17:05 |
kevin.pfeifer |
didn't know the cakephp.org page itself is a accessable repository as well :) I will make a PR which adds the discord link in the same area where the slack link is present |
# |
Jun 22nd 2021, 16:46 |
kevin.pfeifer |
what SQL would you like to represent in such an association? |
# |
Jun 22nd 2021, 16:45 |
ndm |
What would you want that association to use for establishing relations instead? Baked potatoes? |
# |
Jun 22nd 2021, 16:26 |
kevin.pfeifer |
is it possible to add that discord link to https://cakephp.org/get-involved |
# |
Jun 22nd 2021, 16:24 |
kevin.pfeifer |
well hello there |
# |
Jun 22nd 2021, 16:22 |
kevin.pfeifer |
well then you got things to learn :) |
# |
Jun 22nd 2021, 16:21 |
NMND |
I don't even know what slack is. :D |
# |
Jun 22nd 2021, 16:21 |
NMND |
Well I removed all your answer by hitting ctrl which deleted it but as I got most of it, it works now. Many Thanks! :) |
# |
Jun 22nd 2021, 16:21 |
kevin.pfeifer |
and btw: there is a slack channel ;) https://cakesf.herokuapp.com/ |
# |
Jun 22nd 2021, 16:13 |
kevin.pfeifer |
and then just check if that object is empty or not via `if( !empty( $identity ) ):` |
# |
Jun 22nd 2021, 16:13 |
kevin.pfeifer |
basically you can get the $identity object via `$identity = $this->getRequest()->getAttribute( 'identity' );` |
# |
Jun 22nd 2021, 16:12 |
NMND |
That message got ripped apart by no markup within the IRC client. (srsly, why is there no discord? :/ ) but I'll try to sort it and figure it out, thanks! :) |
# |
Jun 22nd 2021, 16:08 |
slackebot1 |
'controller' => 'Users', 'action' => 'login', 'plugin' => 'CakeDC/Users' ] ) ?> <?php endif; ?>``` |
# |
Jun 22nd 2021, 16:08 |
kevin.pfeifer |
```/** @var Authorization\Identity $identity */ $identity = $this->getRequest() ->getAttribute( 'identity' ); <?php if( !empty( $identity ) ): ?> <?= $this->Html->link( sprintf('Logout (%s)', $identity->getOriginalData()->username), [ 'controller' => 'Users', 'action' => 'logout', 'plugin' => 'CakeDC/Users' ] ) ?> <?php else: ?> <?= $this->Html->link( 'Login', [ |
# |
Jun 22nd 2021, 15:52 |
NMND |
Sers. Total Newb using v4.x here. Got through the tutorial. I will need some tutoring until I understand how this works. I HTMLd myself a few buttons into default.php. Now I'd like to replace the login button with a logout button when the user is logged in. Anyone able to spoonfeed or post a up2date tutorial? |
# |
Jun 22nd 2021, 13:00 |
erwane |
it's pretty cool to have localized URL's but .... not really usefull and SEO is not only based on that. |
# |
Jun 22nd 2021, 12:57 |
david |
Thank you guys... I think I will desist in this |
# |
Jun 22nd 2021, 12:56 |
erwane |
Now i'mu using the AdMad i18n plugin and don't translate routes. |
# |
Jun 22nd 2021, 12:56 |
erwane |
Package : <https://packagist.org/packages/erwane/cakephp-i18n-url> Source : <https://github.com/Erwane/cakephp-i18nUrl/tree/4.x> I abandonned the idea. Very complex to maintain. But it work like that : https://pastebin.com/jzXgWJrN |
# |
Jun 22nd 2021, 12:48 |
erwane |
I've done something like that earlier. I'll check if code is public |
# |
Jun 22nd 2021, 12:36 |
kevin.pfeifer |
puh, I haven't dealt with these "translation depths" so sorry, I can't help you any more ,:) |
# |
Jun 22nd 2021, 12:35 |
david |
and I dont't want to du'plicate each url in router.php |
# |
Jun 22nd 2021, 12:34 |
david |
because I can't translate strings in router.php |
# |
Jun 22nd 2021, 12:34 |
david |
No, I have a function "actionDispatcher" |
# |
Jun 22nd 2021, 12:33 |
kevin.pfeifer |
and are you translating urls via `__d('urls', '/english-slug');` ? So do you manually set new routes in your config/router.php if you change some slugs? |
# |
Jun 22nd 2021, 12:32 |
kevin.pfeifer |
the whole translation system relies on the fact, that you stick with one language in your source code and that base language is being translated to whatever is currently active. Therefore your desired functionality can't work. |
# |
Jun 22nd 2021, 12:27 |
david |
I18n::setLocale('es_ES'); echo __('hola'); // prints "hola" I18n::setLocale('en_GB'); echo __('hola'); // prints "hello" The problem, because I am trying to translate a translation: I18n::setLocale('es_ES'); echo __('hello'); // prints "hello" |
# |
Jun 22nd 2021, 12:24 |
dereuromark |
you could switch the translation language at runtime for each, and then reset. but it might be easier to just hardcode this one then. |
# |
Jun 22nd 2021, 12:23 |
david |
when I "paint" the link to change to spanish version, I can't obtain the spanish string because I am trying to translate __d('urls', '/english-slug'); |
# |
Jun 22nd 2021, 12:22 |
david |
the problem is when I am in english (mydomain.com/en) |
# |
Jun 22nd 2021, 12:22 |
david |
no, that works fine |
# |
Jun 22nd 2021, 12:21 |
kevin.pfeifer |
but when changing to english, you want to load the text from the `en/default.po` and it doesn't` |
# |
Jun 22nd 2021, 12:21 |
david |
in spanish there is no problem |
# |
Jun 22nd 2021, 12:21 |
david |
yes, that is |
# |
Jun 22nd 2021, 12:20 |
kevin.pfeifer |
so your spanish text is all good and if your current active language is spanish then everything is fine, right? |