wilr / silverstripe-googlesitemaps

Google Sitemaps module for the SilverStripe CMS
BSD 3-Clause "New" or "Revised" License
74 stars 95 forks source link

Sitemaps empty for DataObjects #164

Closed Gregor-Agnes closed 4 years ago

Gregor-Agnes commented 4 years ago

Hi and thx again for this fine extension! Have implemented a sitemap for a Data Object with mor than 1000 objects. The sub-sitemaps /1 and /2 are linked, but they are empty.

I hade to implement the funciton

public function canIncludeInGoogleSitemap()
    {
        return true;
    }

in the Model-Class. Than it works. I don't think, this is the right way. But ist there another way? I think it has to do with this part

// Subsite support
            if (class_exists(Subsite::class)) {
                // Subsite will have a different domain from Director::protocolAndHost
                if ($subsite = Subsite::currentSubsite()) {
                    $hostHttp = parse_url(Director::protocol() . $subsite->getPrimaryDomain(), PHP_URL_HOST);
                }
            }

in GoogleSitemapExtension.php but I don't know how or why :)

wilr commented 4 years ago

@Gregor-Agnes that filter should only apply if you have subsites installed - Do you have this module running?

The other thing to check is do you define a canView on your DataObject which could be causing records to be hidden. Only records which return true for canView() will display on the sitemap.

Gregor-Agnes commented 4 years ago

No, subsite ist not installed.

Yes, I defined canView():

public function canView($member = null)
{
    return Permission::check('CMS_ACCESS_JobAdmin', 'any', $member);
}

Strange thing is: it works on my local copy of the page, it does not work on the live site.

wilr commented 4 years ago

As mentioned, canView must return true for the records to appear in the XML file. It works on your local as you're logged in.