The way to accomplish this is to create a SitemapGenerator plugin and implement getXml().
The problem:
If extending DefaultSitemapGenerator, there is no way to add custom properties to each entry. Instead, the entire code of DefaultSitemapGenerator::getXml() must be copied and modified.
Proposed solution:
Move the code that is currently inside the foreach ($links as $link)
loop into its own method. It could be called something like processLinkForXml()
or writeUrl
, since it is creating a single url node with some child nodes.
I think it makes sense to make this change in DefaultSitemapGenerator, so that if others only want to add properties, the solution is to extend the class, override writeUrl
(or whatever it's named), call parent::writeUrl()
, then make other additions to the XML node.
Comment | File | Size | Author |
---|---|---|---|
#3 | 3062820-add-custom-xml-nodes.patch | 4.84 KB | nadavoid |
|
Comments
Comment #2
gbyte CreditAttribution: gbyte as a volunteer and at gbyte commentedGood idea, looking forward to a patch!
Comment #3
nadavoid CreditAttribution: nadavoid at Phase2 commentedPatch attached. Used
buildUrl()
as the function name.Tested locally in an extending class, using code like this:
Comment #5
gbyte CreditAttribution: gbyte as a volunteer and at gbyte commentedI've taken it further and compartmentalized a little more. Please test dev and get back to me.