sitemap icon indicating copy to clipboard operation
sitemap copied to clipboard

addCategoryGroup Service not working

Open rubenwebs opened this issue 10 years ago • 2 comments

Hi,

Nice plugin, but the service addCategoryGroup doesn't work.

Your example code is:

$group = craft()->categories->getGroupByHandle('news'); craft()->sitemap->addCategoryGroup($group);

But it doesn't return any categories, because this line isn't right (Line 145 - SitemapService.php): $criteria->group = $categoryGroup;

The parameter expects a string, but you're putting in the whole CategoryGroupModel instead. There are two options of fixing:

  1. Change the function to: public function addCategoryGroup($categoryGroup, $changefreq = null, $priority = null)

And change the example code to: craft()->sitemap->addCategoryGroup('news');

  1. Or change line 145 to: $criteria->group = $categoryGroup->handle;

Hope this helps, Ruben

rubenwebs avatar Dec 02 '15 11:12 rubenwebs

Thanks, Ruben.

Care to ping over a PR? :wink:

On 2 Dec 2015, at 11:38 a.m., Ruben [email protected] wrote:

Hi,

Nice plugin, but the service addCategoryGroup doesn't work.

Your example code is:

$group = craft()->categories->getGroupByHandle('news'); craft()->sitemap->addCategoryGroup($group);

But it doesn't return any categories, because this line isn't right (Line 145 - SitemapService.php): $criteria->group = $categoryGroup;

The parameter expects a string, but you're putting in the whole CategoryGroupModel instead. There are two options of fixing:

Change the function to: public function addCategoryGroup($categoryGroup, $changefreq = null, $priority = null) And change the example code to: craft()->sitemap->addCategoryGroup('news');

Or change line 145 to: $criteria->group = $categoryGroup->handle; Hope this helps, Ruben

— Reply to this email directly or view it on GitHub.

joshuabaker avatar Dec 02 '15 12:12 joshuabaker

Like so?

rubenwebs avatar Dec 02 '15 12:12 rubenwebs