I want to override the SeoStructureExtension with my own implementation, which will support OpenGraph (OG) tags.
What is the easiest way to override it and add additional inputs?
I am afraid to say that overriding the SeoStructureExtension
file can not be achieved very easily... The fields it saves are hardcoded. So the first thing you would have to do is override the sulu_page.extension.seo
service, which references this class. I would say your best bet to achieve this, is to decorate this service.
The other part you have to extend is the XML file describing the page_seo
form. Luckily this part is a little bit easier. Your Sulu installation should already come with a config/forms
folder, where you can put a file similar to the original page_seo
form. Give it the same key (page_seo
) and only add the new fields you want to add (the name of the properties have to match what you are implementing in the decorated service). If you e.g. want to add a new text field, this file would look something like this:
<?xml version="1.0" ?>
<form xmlns="http://schemas.sulu.io/template/template"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://schemas.sulu.io/template/template http://schemas.sulu.io/template/form-1.0.xsd"
>
<key>page_seo</key>
<properties>
<property name="ext/seo/ogTitle" type="text_line">
<meta>
<title lang="en">OG Title</title>
</meta>
</property>
</properties>
</form>
Mind the ext/seo/
prefix before ogTitle
, which is need for the information to be passed to the SeoStructureExtension
.
I also think that these fields might make sense to be added to the core of Sulu. I would be happy if you create an issue, explaining what fields exactly you need etc. Then we can discuss if we implement it in the core as well, so that you don't have to add this manually in future versions.