Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make SEO Tab extendable and make it simpler to handle #266

Open
alexander-schranz opened this issue Aug 9, 2024 · 0 comments
Open

Make SEO Tab extendable and make it simpler to handle #266

alexander-schranz opened this issue Aug 9, 2024 · 0 comments
Assignees
Labels
Feature New functionality not yet included in Bundle

Comments

@alexander-schranz
Copy link
Member

alexander-schranz commented Aug 9, 2024

The SEO Tab should be extendable over XML mechanism of Sulu. At current state create a lot of unneeded SEO fields which we could also store as JSON object we already do for template data. The only field which is required for filtering is currently the seoHideInSitemap all other fields we could store into a JSON field:

 if ($reflection->implementsInterface(SeoInterface::class)) {
-    $this->addField($metadata, 'seoTitle');
-    $this->addField($metadata, 'seoDescription', 'text');
-    $this->addField($metadata, 'seoKeywords', 'text');
+    $this->addField($metadata, 'seoData', 'json', ['nullable' => false, 'options' => ['jsonb' => true]]);
-    $this->addField($metadata, 'seoCanonicalUrl', 'text');
-    $this->addField($metadata, 'seoNoIndex', 'boolean');
-    $this->addField($metadata, 'seoNoFollow', 'boolean');
     $this->addField($metadata, 'seoHideInSitemap', 'boolean');
+    $this->addIndex($metadata, 'idx_seo_hide_in_sitemap', ['seoHideInSitemap']);
 }

In this case we may change the content_seo.xml to put SEO again into ext/seo like we already done previosly in the page_seo. This may also resolve the SERP currently not working: #79

To support this we need introduce also a SeoNormalizer so the seoData field get correctly returned under ['ext']['seo']: https://github.com/sulu/SuluContentBundle/tree/0.8.1/Content/Application/ContentNormalizer/Normalizer So Seo fields are not returned on the root level instead again under ext/seo.

The setSeoData and getSeoData could look like this:

public function setSeoData(array $seoData): void {
    if (\array_key_exists('hideInSitemap', $seoData)) {
         $this->seoHideInSitemap = $seoData['hideInSitemap'];
         
         unset($seoData);
    }
    
    $this->seoData = $seoData;
}

public function getSeoData(): {
    $seoData = $this->seoData;
    $seoData['hideInSitemap'] = $this->seoHideInSitemap;
    
    return $seoData
}

That way we can remove the different setters.


The change is a BC break and require a SQL upgrade in the UPGRADE.md.


The exptected result is if somebody creates inside of its own project a config/form/content_seo.xml it should add that new field and save it also to the seoData json field:

<?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>content_seo</key>

    <properties>
        <property name="ext/seo/custom" type="text_line">
            <meta>
                <title>Custom Field</title>
            </meta>
        </property>
    </properties>
</form>

We may could add should add to our test application such file: https://github.com/sulu/SuluContentBundle/tree/0.8.1/Tests/Application/config and test it in the ExampleTestController

@alexander-schranz alexander-schranz changed the title Change handling of SEO Tab to support extending of SEO tab Make SEO Tab extendable and make it simpler to handle Aug 9, 2024
@alexander-schranz alexander-schranz added the Feature New functionality not yet included in Bundle label Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New functionality not yet included in Bundle
Projects
None yet
Development

No branches or pull requests

2 participants