In the application I am working on, I use the 'Slug' plugin - I can fetch records in the default language without any problems, but I am unable to do so in the translated languages. A simplified PHP code looks like this:
public function index($slug=null)
{
$this->ServiceUnits = $this->fetchTable('ServiceUnits');
$serviceUnit = $this->ServiceUnits->find('slugged', slug: $slug)->first();
}
CREATE TABLE IF NOT EXISTS `service_units` (
`id` int NOT NULL AUTO_INCREMENT,
`title` varchar(255) DEFAULT NULL,
`text` text,
`slug` varchar(100) DEFAULT NULL,
`active` tinyint(1) NOT NULL DEFAULT '0',
`position` float DEFAULT NULL,
PRIMARY KEY (`id`)
);
CREATE TABLE IF NOT EXISTS `service_units_translations` (
`id` int NOT NULL,
`locale` varchar(5) NOT NULL,
`title` varchar(255) DEFAULT NULL,
`text` text,
`slug` varchar(100) DEFAULT NULL,
PRIMARY KEY (`id`,`locale`)
);
How can I retrieve data from the service_units_translations table using the 'Slug' plugin?
In the application I am working on, I use the 'Slug' plugin - https://github/UseMuffin/Slug I can fetch records in the default language without any problems, but I am unable to do so in the translated languages. A simplified PHP code looks like this:
public function index($slug=null)
{
$this->ServiceUnits = $this->fetchTable('ServiceUnits');
$serviceUnit = $this->ServiceUnits->find('slugged', slug: $slug)->first();
}
CREATE TABLE IF NOT EXISTS `service_units` (
`id` int NOT NULL AUTO_INCREMENT,
`title` varchar(255) DEFAULT NULL,
`text` text,
`slug` varchar(100) DEFAULT NULL,
`active` tinyint(1) NOT NULL DEFAULT '0',
`position` float DEFAULT NULL,
PRIMARY KEY (`id`)
);
CREATE TABLE IF NOT EXISTS `service_units_translations` (
`id` int NOT NULL,
`locale` varchar(5) NOT NULL,
`title` varchar(255) DEFAULT NULL,
`text` text,
`slug` varchar(100) DEFAULT NULL,
PRIMARY KEY (`id`,`locale`)
);
How can I retrieve data from the service_units_translations table using the 'Slug' plugin?
Share Improve this question asked Nov 20, 2024 at 11:05 user3661042user3661042 1671 silver badge13 bronze badges1 Answer
Reset to default 0The problem was solved in this way: https://book.cakephp./5/en/orm/behaviors/translate.html#querying-translated-fields