[SEO Storm Plugin] Use Model Data within the title

I have a quick question about the SEO Storm Plugin:
https://octobercms.com/plugin/initbiz-seostorm

Within the documentation it says, that you can access model data for the page title etc, for example the twig syntax {{ question.question }} is used to fill the title. But I wonder how this is done. Where do I get the model name from? Do I have to prepare something in order to make it accessible?

Since the seo component should be rendered within the heads section and the component with the content (and the model where I would like to grab the data from) comes after this, the model is not initialized in the frontend yet. Therefor I’m not surprised my attempts to get variables from the model do not work.

But I wonder what I have to do in order to make this work.

Or do I still have to set a property to the page variable within my components code in order to use it?
https://docs.octobercms.com/2.x/cms/pages.html#page-variables

Quite stuck here, so any help is welcome. Thanks a lot ^^

I think the page lifecycle is important here: Layouts - October CMS - 2.x (v2), Layouts - October CMS - 3.x (v3)

You have to prepare all the data in the onInit() function of the layout or the page, that should make the data available for the rest of your code. Where you initialize it depends on your sites structure. If you have a special layout for that site, I’d use that layout. If you have a component, you can use the onInit() function there to inject variables into the page.

2 Likes

Well, this helped:

Component: $this->page['record'] = $this->record;
Page Settings: seoOptionsOgTitle = "{{ record.name }}"

OR

Component: $this->page->record = $this->record;
Page Settings: seoOptionsOgTitle = "{{ this.page.record.name }}"

Just thought there’s a different and more direct way directly in the model.

I used this in the onRun() method of the component.

So… if there’s no better way the problem is solved.

I’m just surprised SEO Storm does not provide options for keywords, or did I miss those?

1 Like