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

Add Sitemap model hooks #1231

Closed
Markarend opened this issue Jun 10, 2020 · 4 comments
Closed

Add Sitemap model hooks #1231

Markarend opened this issue Jun 10, 2020 · 4 comments

Comments

@Markarend
Copy link

I'm trying to use a sitemap hook to be able to act whenever the sitemap is changed from the manager (so I can use it to update my search index with page hierarchy metadata). I added what I think is necessary, but am not seeing my hook being called. Can someone advise what is necessary to get this hook working?

In Startup, in Configure method, after App.Init(api) :

        App.Hooks.OnGenerateSitemap += (sitemap) =>
        {
            // Add custom items to the sitemap before rendering Sitemap.xml
            return ProcessUpdates(sitemap);
        };

In Startup, my custom method :

    public Sitemap ProcessUpdates(Sitemap sitemap)
    {
        int dbg = 1; // just so I can set the debugger here and inspect sitemap
        return sitemap;
    }

The debugger never stops in my ProcessUpdates method, when I update the sitemap in manager by dragging pages around, though I see "The sitemap was successfully updated" toast in manager.

@r4g-jon
Copy link
Contributor

r4g-jon commented Jun 11, 2020

Hi @Markarend

I think the hook for the sitemap works when someone requests the sitemap.xml file on the website. I don't think the hook fires from within the manager.

@tidyui
Copy link
Member

tidyui commented Jun 11, 2020

Hi @Markarend! Just like @r4g-jon wrote the hook you mention is actually for generating Google Sitemap, but I can see how the name is slightly confusing, we'll think about a future name-change to make it more clear.

For search-indexes there is a service API that you can implement called ISearch that you can find here:

https://github.com/PiranhaCMS/piranha.core/blob/master/core/Piranha/ISearch.cs

This service gets called every time a page or post is updated or deleted. You can take a look at how we use this interface in our search module for Azure Search we're working on here:

https://github.com/PiranhaCMS/piranha.core/tree/master/core/Piranha.Azure.Search

Best regards

@Markarend
Copy link
Author

Hakan, thank you very much for your quick reply, this will definitely help us!
Is there any service or event I can consume to be notified when the Piranha sitemap is updated by moving pages around on the manager?

@tidyui
Copy link
Member

tidyui commented Jun 11, 2020

Not at the moment.. But we can add one for 8.4. I'll rename this issue to reflect it

@tidyui tidyui changed the title How to use sitemap hook? Add Sitemap model hooks Jun 11, 2020
@tidyui tidyui added this to the Version 8.4 milestone Jun 11, 2020
@tidyui tidyui self-assigned this Jun 25, 2020
@tidyui tidyui closed this as completed in 3fcd5ca Jun 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants