Re: Google Sitemap generation - double links

Sebastian Tänzer <[email protected]> Fri, 27 Jan 2012 12:12:30 +0100
Newsgroups gmane.comp.cms.zms.devel
Message-ID <[email protected]>
I found the problem:

getHref2IndexHtml() generated the URL of the next child if the parent doesn't have any content (i.e. there's only folders in there).
I solved this for now by using a python script checking for content like this:

request = container.REQUEST
response =  request.response

nodes = context.filteredChildNodes()
folder_types = ['ZMSFolder', 'ZMSDocument']
content = []

for n in nodes:
    if n.meta_id not in folder_types:
        content.append(n.meta_id)

if content:
    return True
else:
    return False

and including it in the sitemap generation:

...
<dtml-in "content.filteredTreeNodes(REQUEST=REQUEST, meta_types=['ZMSFolder'])">
    <dtml-if "checkContent() and not isResource(REQUEST) and isActive(REQUEST)">
      <url>
        <loc><dtml-var domain><dtml-var "getHref2IndexHtml(REQUEST)" html_quote></loc>
        <lastmod><dtml-var "getLangFmtDate(ZopeTime(),'eng','%Y-%m-%d')"></lastmod>
        <dtml-comment><lastmod><dtml-var "getLangFmtDate(getObjProperty('change_dt',REQUEST),'eng','%Y-%m-%d')"></lastmod></dtml-comment>
        <dtml-if "getObjProperty('attr_zmsgoogle_bot_priority',REQUEST)"><priority><dtml-var "getObjProperty('attr_zmsgoogle_bot_priority',REQUEST)" fmt="%.5f"></priority><dtml-else></dtml-if>
        <dtml-if "getObjProperty('attr_zmsgoogle_bot_changefreq',REQUEST)"><changefreq><dtml-var "getObjProperty('attr_zmsgoogle_bot_changefreq',REQUEST)"></changefreq><dtml-else></dtml-if>
      </url>
    </dtml-if>
</dtml-in>   
...

This works as expected for now.

Optimizations highly welcome!

Cheers, Sebastian

Am 27.01.2012 um 11:32 schrieb Niels Dettenbach:

> Am Freitag, 27. Januar 2012, 11:12:28 schrieben Sie:
>> any idea about the double output of some folders?
> ...not yet, as i can't reproduce this (at least with my published version).
> 
> Will check this (i.e. if it relies on some hidden folders or something like 
> that) on wednesday next week in detail and come back then.
> 
> 
> best regards,
> 
> 
> Niels.
> -- 
> ---
> Niels Dettenbach
> Syndicat IT&Internet
> http://www.syndicat.com/