Yoast / Yoast-SEO-for-TYPO3

Yoast SEO plugin for TYPO3
Other
51 stars 56 forks source link

Automatic functionality for records not working #550

Open ste101 opened 1 year ago

ste101 commented 1 year ago

I tried to add the Yoast field to an extension via 'automatic functionality' but I'm having some problems. This is my configuration:

\YoastSeoForTypo3\YoastSeo\Utility\RecordUtility::configureForRecord('tx_sfeventmgt_domain_model_event')
     ->setGetParameters([
         ['tx_sfeventmgt_pieventdetail', 'event'],
     ])
     ->setSitemapFields(false)
     ->setAddDescriptionField('seo_description')
     ->setDescriptionField('seo_description')
     ->setFieldsPosition('after:custom_text');

The field will show up in backend but 'SitemapFields' show up, 'description' also although I set ->setAddDescriptionField('seo_description') ->setDescriptionField('seo_description') grafik

The biggest problem is that the seo field are not added to the database and so I'm getting errors like PHP Warning: Undefined array key "og_image" in /html/typo3/typo3conf/ext/yoast_seo/Classes/MetaTag/Generator/OpenGraphGenerator.php line 29 Preview config:

TCEMAIN.preview {
    tx_sfeventmgt_domain_model_event {
        previewPageId = 10
        useCacheHash = 1
        useDefaultLanguageRecord = 0
        fieldToParameterMap {
                uid = tx_sfeventmgt_pieventdetail[event]
        }
        additionalGetParameters {
                tx_sfeventmgt_pieventdetail.controller = Event
                tx_sfeventmgt_pieventdetail.action = detail
        }
    }
}

Technical info

RinyVT commented 1 year ago

Hi @ste101!

I have tested with the extension sf_event_mgt, if the seo_description field is a new field you wish to add then the setAddDescriptionField should be a boolean true instead of a string. In this case a new field will be added to TCA and database, based on the description field of the pages table.

The extra description field which is seen below the cornerstone field, is because the sf_event_mgt already has a description field and the seo palette from pages is being copied and that palette already contains the description field.

In this case I think the only way to prevent that is to override the palette, the total configuration will look like this:

\YoastSeoForTypo3\YoastSeo\Utility\RecordUtility::configureForRecord('tx_sfeventmgt_domain_model_event')
    ->setGetParameters([
        ['tx_sfeventmgt_pieventdetail', 'event']
    ])
    ->setSitemapFields(false)
    ->setAddDescriptionField(true)
    ->setDescriptionField('seo_description')
    ->setFieldsPosition('after:custom_text')
    ->setOverrideTca([
        'palettes' => [
            'seo' => [
                'showitem' => '--linebreak--, tx_yoastseo_snippetpreview,
                    --linebreak--, seo_title;LLL:EXT:seo/Resources/Private/Language/locallang_tca.xlf:pages.seo_title,
                    --linebreak--, seo_description,
                    --linebreak--, tx_yoastseo_cornerstone,'
            ]
        ]
    ]);

Sidenote: the sf_event_mgt already has a meta_description field, this may conflict with your custom seo_description field.

Regarding the sitemap fields and the errors in the frontend, those are indeed bugs. I will open a bugfix PR as soon as possible!

RinyVT commented 1 year ago

@ste101 I have just added a PR: https://github.com/Yoast/Yoast-SEO-for-TYPO3/pull/553, could you test this?

Regarding the fields not being added to the database, when you run the database analyzer (after clearing system cache) the fields do not show up?

Regarding the preview, it looks like there's no absolute URL being generated, two things to check:

ste101 commented 1 year ago

Regarding the fields not being added to the database, when you run the database analyzer (after clearing system cache) the fields do not show up?

Yes they show up. I thought that they are added automatically. Could you add a sentence about this to the docu?

I tried to reuse the exitings fields alternative_title and meta_description. They show up in SEO tab but the progress bar does not show up: grafik I used ->setTitleField('alternative_title') but the database analyser still shows ALTER TABLE tx_sfeventmgt_domain_model_event ADD seo_title VARCHAR(255) DEFAULT '' NOT NULL

Removing the configured fields from the Metadata tab would be great also as you doing this at the page properties.

Maybe it would be got to have the possibility to switch off twitter and opengraph.

Thank you very much.

ste101 commented 7 months ago

The progress bars and the preview update still does not work. I can see this error message in the browser console: grafik