[opencms-dev] Google Site Maps

Shi Yusen shiys at langhua.cn
Tue Feb 27 06:37:18 CET 2007


Here is another well-designed implement donated by Tim Howland:
http://mail.opencms.org/pipermail/opencms-dev/2005q4/019952.html

Regards,

Shi Yusen/Beijing Langhua Ltd.


在 2007-02-26一的 17:20 -0500,Isaac R. Higgins写道:
> I have been searching for an basic opencms google sitemap XML generator all day.  I know no one asked for this, but I'm going to send it to the list anyway just in case someone is looking for one in the future.
> 
> https://www.google.com/webmasters/tools/docs/en/protocol.html#sitemapXMLFormat
> 
> I just created a file "sitemap.xml" in the root of my site with the following source:
> 
> -----------------------------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %><%@ 
>     taglib prefix="c" uri="http://java.sun.com/jstl/core" %><%@ 
>     page import="com.opencms.flex.jsp.*,com.opencms.file.*,java.util.*" %>
> <jsp:useBean id="cmsbean" class="org.opencms.jsp.CmsJspBean">
>   <% cmsbean.init(pageContext, request, response); %>
> </jsp:useBean><%
> 
> java.util.List alist = (new org.opencms.jsp.CmsJspNavBuilder()).getSiteNavigation(cmsbean.getCmsObject(), "/" ,-1);
> 
> %>
>   <urlset xmlns="http://www.google.com/schemas/sitemap/0.84">
> <% for (int i=0;i<alist.size();++i){%>
> <%
> 	org.opencms.file.CmsResource ress = null;
> 	java.util.Date date1 = new java.util.Date();
> 	try{
> 		ress = org.opencms.main.OpenCms.initResource(cmsbean.getCmsObject(),
> 			(((org.opencms.jsp.CmsJspNavElement)alist.get(i)).getResourceName()),
> 			request,
> 			response);
> 		date1 = new java.util.Date(ress.getDateLastModified());
> 	}catch(Exception e){}
> 	
> 	int year = date1.getYear()+1900;
> 	int day = date1.getDate();
> 	int month = date1.getMonth()+1;
> %>
>    <url>
>     <loc><%= ((org.opencms.jsp.CmsJspNavElement) alist.get(i)).getResourceName() %></loc>
>     <lastmod><%= year %>-<%= month %>-<%= day %></lastmod>
>     <changefreq>weekly</changefreq>
>     <priority>0.5</priority>
>    </url>  
> <%}%>
>   </urlset> 
> ------------------------------------------------------
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://lists.opencms.org/mailman/listinfo/opencms-dev




More information about the opencms-dev mailing list