This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

amit.erandole132
amit.erandole132

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.

Daniel81
Daniel81

Why would you want meta keywords? Aren't they largely ignored by search engines nowadays?

amit.erandole132
amit.erandole132

It's a client requirement. But besides, I want to know how to append to existing fields

codivist
codivist

@amit, did you ever get this figured out? I'm trying to extend a form on the user plugin, but having problems.

Flynsarmy
Flynsarmy

@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

Daniel81
Daniel81
'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

codivist
codivist

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.

masterdevijay10516
masterdevijay10516

Please provide the folder path, as its difficult to goahead

2create
2create

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\

tony_p4620282
tony_p4620282

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

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.