clickstorm / cs_seo

[clickstorm] SEO

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JSON-LD field not shown for custom records

creationell opened this issue · comments

We've written an extension with multiple entities that we want to extend with cs_seo metadata. While it is really easy to add the relation and database field as described here, we've experienced a bug with the JSON-LD field. The text field is not rendered at all (see screenshot below, I also checked the HTML markup - it's empty). For pages, the field is rendered as expected.

image

  • TYPO3 10.4.16
  • cs_seo 6.4.0

Hey. Thanks for report. I have a TYPO3 10.4.17. Does it work there? In my setup it works as it should

17-06-_2021_08-26-55

Okay, found the problem:

In JsonLdElement.php you do sth. like this:

if (isset($GLOBALS['TSFE'])) {                    
   $siteTitle = $TSFEUtility->getSiteTitle();                    
   $pageTitleSeparator = $TSFEUtility->getPageTitleSeparator();                    
   $config = $TSFEUtility->getConfig();
        if ($table == 'pages') {                        
             $GLOBALS['TSFE']->config['config']['noPageTitle'] = 0;
             $GLOBALS['TSFE']->generatePageTitle();
             $pageTitle = static::getPageRenderer()->getTitle();
              // get page path                        
              $path = $TSFEUtility->getPagePath();
              
         } else {
             // other records

In other words: you're heavily relying on TSFE being present for pages records. For other records (the else part), you're not using TSFE at all. Thus, it should be no problem to move the outer if inside the inner.

While I'm writing: Thanks for the quick reply. I will check with 10.4.17 as well.

Still the same behavior on 10.4.17

May I contribute a PR?

I don't get it, why it is a problem in your setup and not in mine. Where are your records stored? Is there a site config and a TypoScript Template?

A PR is allways welcome.

I've justz opened the PR. My guess is that the TSFE is available in this context randomly - in your case it is, in mine it's not.

Sry for the late response. You're right, to load the TSFE is here not necessary. Thank you a lot. The changes will be included in the next release.