Skip to content
This repository was archived by the owner on Apr 22, 2024. It is now read-only.

sitemap job refactoring to improve extensibility - #1271

Merged
aembler merged 1 commit into
concretecms:masterfrom
Remo:refactor-sitemap-job
Feb 7, 2014
Merged

sitemap job refactoring to improve extensibility#1271
aembler merged 1 commit into
concretecms:masterfrom
Remo:refactor-sitemap-job

Conversation

@Remo

@Remo Remo commented Aug 8, 2013

Copy link
Copy Markdown
Contributor

I've had some issues when I wanted to override the sitemap job.
All I wanted to do is to add some custom entries without overriding the whole file.

Unfortunately most of the logic was in run(), a method I didn't want to override.

I created a new method "AddPages" which you can override. At this point you can easily add additional entries to the xml file, no need to override the whole run method or remove first

@mlocati

mlocati commented Aug 8, 2013

Copy link
Copy Markdown
Contributor

@Remo are you thinking about the GenerateMultilingualSitemap job of the multilingual package, aren't you?
I also would like to optimize the somehow duplicated functions of the two jobs generating sitemap.xml (GenerateSitemap and GenerateMultilingualSitemap).
What about moving the AddPages somehow to the Page or PageList models and adding an event for each generated xml node? In this way the multilingual package could simply intercept this event and doing its stuff within this event...

@Remo

Remo commented Aug 8, 2013

Copy link
Copy Markdown
Contributor Author

@mlocati No, it's not about GenerateMultilingualSitemap. We've got quite a few projects with page type controllers. There are methods we call and get different content based on the parameters. /page/object-123 while object-123 is a database object and not a page object. I'd like to make sure Google finds those as well and wanted to override.

Nothing else than additional pages I'd like to add to sitemap.xml

However, I do see that GenerateMultilingualSitemap might benefit from a refactoring. I'm not sure if that method fits well into Page or PageList, generating sitemap.xml seems to be pretty specific to this job.

I also thought about adding two new events
on_sitemap_xml
on_page_sitemap_xml

The first would get called once for every job run and the second one would get called for every page found in the job.

I'll keep on thinking about that, but so far, the "AddPages" method is all I need.

@mlocati

mlocati commented Aug 8, 2013

Copy link
Copy Markdown
Contributor

@Remo Ok. BTW we could also leave the AddPage inside the GenerateSitemap job, add those two events.
This way the GenerateMultilingualSitemap job of the multilingual package is useless: multilingual could simply doing its stuff byintercepting the events (and there's less problems in having two jobs generating sitemap.xml).

As a side note, I can't remember why I kept two separated calls to AddPage for the home and the other pages: now that you're touching the GenerateSitemap job, could you remove the self::AddPage($hFile, 1, $instances) line and the WHERE (cID > 1) sql condition?

@Remo

Remo commented Aug 8, 2013

Copy link
Copy Markdown
Contributor Author

@mlocati cID > 1 stuff removed

@mlocati

mlocati commented Aug 8, 2013

Copy link
Copy Markdown
Contributor

Useless stuff removed almost everywhere ;)

@Remo

Remo commented Aug 8, 2013

Copy link
Copy Markdown
Contributor Author

thanks @mlocati

Add events to GenerateSitemap job
@Remo

Remo commented Aug 9, 2013

Copy link
Copy Markdown
Contributor Author

The changes made by @mlocati add two events as described above and also introduce SimpleXML. The memory overhead is a bit bigger but the code is much cleaner and easier to extend, more about that here Remo#2

@aembler

aembler commented Nov 2, 2013

Copy link
Copy Markdown
Member

Accidentally closed this earlier.

@aembler aembler reopened this Nov 2, 2013
@aembler
aembler merged commit 82d2053 into concretecms:master Feb 7, 2014
@aembler

aembler commented Feb 7, 2014

Copy link
Copy Markdown
Member

Thanks guys this looks good.

@mlocati

mlocati commented Feb 11, 2014

Copy link
Copy Markdown
Contributor

@Remo
Remo deleted the refactor-sitemap-job branch March 18, 2014 11:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants