-
Hello! I would like to add fields for SEO like og:title, og:image, ... Now I'm trying to add custom fields by default on all my staticPages by extending the staticPages plugin. I managed to do this. In my layout I can use the variable like so: {{ og_title }}.
I have been searching and reading for several hours but I can't find anything that works. I'm a front-end developer so I might've done stuff wrong. Can anyone help me to get RainLab.Translate to work with my code? Thank you for your time! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 9 replies
-
You need to add the new fields to the translatable property of the model. See Winter.Translate documentation |
Beta Was this translation helpful? Give feedback.
-
Finally found a solution to translate custom, extended backend fields. After several days I found the solution here: https://octobercms.inetis.ch/advanced-repeaters-static-pages-plugin. Thank you Christophe Vuagniaux! Below the super simple solution, I hope this will help many people out! I created a plugin using
So yes, it is super easy, once you find the correct solution amongst many many wrong posts. Note:
|
Beta Was this translation helpful? Give feedback.
-
You should really be using custom page fields for this. You can add |
Beta Was this translation helpful? Give feedback.
Finally found a solution to translate custom, extended backend fields.
I searched and tried everything in the documentation and other peoples posts/threads but I couldn't make it work at all.
After several days I found the solution here: https://octobercms.inetis.ch/advanced-repeaters-static-pages-plugin. Thank you Christophe Vuagniaux!
Below the super simple solution, I hope this will help many people out!
All you have to do is add:
$widget->model->translatable = [ 'viewBag[og_title]', 'viewBag[og_description]' ];
You can add as many fields as you want. All the fields will show up, translatable, in each staticPage.
I created a plugin using
php artisan create:plugin aic.extendStaticPages
…