This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
I want to add a meta keywords
field to the meta
tab on the pages interface.
So I created a plugin called keywords
and in the Plugin.php
file I added this code in the register hook:
public function register()
{
Event::listen('backend.form.extendFields', function($widget) {
if (!$widget->model instanceof \Cms\Classes\Page) return;
$widget->addFields([
'settings[menu_text]' => [
'label' => 'Meta Keywords',
'tab' => 'Meta',
'span' => 'left',
],
], 'primary');
});
}
Now this adds another tab called Meta with the new field. I want this field to appear in the existing Meta field. Also I want to know how to save the data the user inputs in the field and then access it out on the template level.
It's a client requirement. But besides, I want to know how to append to existing fields
@amit, did you ever get this figured out? I'm trying to extend a form on the user plugin, but having problems.
@codivist there are so many plugins that extend other plugins. it shoudl be ridiculously simple to find a working code sample. For example have you looked at RainLab.Forum
's Plugin.php?
Last updated
'settings[menu_text]' => [
'label' => 'Meta Keywords',
'tab' => 'cms::lang.editor.meta',
'span' => 'left',
],
Access it in the layout using:
{{ this.page.menu_text }}
Last updated
Thanks @Flynsarmy and @Daniel81, I was able to play around with things, and just starting trying stuff, I've got some working and some not, but I'm heading in the right direction.
i know, its not OK, but u can add this:
settings[meta_keywords]: tab: cms::lang.editor.meta label: cms::lang.editor.meta_keywords type: textarea size: tiny
to file fields.yaml under cms\classes\page\
create2 is correct but you also need to add this 'meta_keywords' => 'Meta Keywords', to the 'editor'=> sectoin of the lang.php file
1-10 of 10