0

フィールド内の各言語のデータを配列として取得する必要があります。おそらく、CakePHP での最良のアプローチは、Set::combine動作させることができません。手動で行うことはできますが、それforeachが最善の方法になるとは思いません。

次に例を示します。

Array
    (
        [Article] => Array
            (
                [id] => 131
                [title] => TEST
            )

        [titleTranslation] => Array
            (
                [0] => Array
                    (
                        [id] => 62
                        [locale] => eng
                        [model] => Article
                        [foreign_key] => 131
                        [field] => title
                        [content] => TEST
                    )
                [1] => Array
                    (
                        [id] => 63
                        [locale] => fre
                        [model] => Article
                        [foreign_key] => 131
                        [field] => title
                        [content] => Salva
                    )
                [2] => Array
                    (
                        [id] => 64
                        [locale] => rus
                        [model] => Article
                        [foreign_key] => 131
                        [field] => title
                        [content] => Пвет
                    )
            )
    )

この配列に:

Array
    (
        [Article] => Array
            (
                [id] => 131
                [title] =>  Array
                    (
                        [eng] => TEST
                        [fre] => Salva
                        [rus] => Пвет
                    )
            )

        .... the rest is not important

    )

解決済み-----

            $translatedData = Set::combine($this->data['titleTranslation'], '{n}.locale', '{n}.content', '{n}.field');
            $this->data['Article'] = array_merge($this->data['Article'], $translatedData);
4

0 に答える 0