Skip to end of metadata
Go to start of metadata

You are viewing an old version of this content. View the current version.

Compare with Current View Version History

« Previous Version 3 Next »

Overview

Sitemaps facility in farcry lets you dynamically create a google sitemap with just a few lines of code.

Create a webskin under /webskins/dmNavigation or under another type if needed. In this example we'll call it displayTypeSiteMap.cfm. Add the following code.

./webskins/dmNavigation/displayTypeSiteMap.cfm
<!--- @@fuAlias: sitemap --->
<cfset oSiteMap=createObject('component', 'farcry.core.packages.googleSiteMap.sitemap').init()>
<cfset stSiteConfig=structNew()>
<cfset stSiteConfig.domainName="#cgi.server_name#">

<cfset xml=oSiteMap.generate(stSiteConfig=stSiteConfig,siteMapType="siteMap", types="dmNavigation")>
<CFHEADER NAME="content-disposition" VALUE="inline; filename=#url.type#.#now()#">
<cfheader name="Content-Type" value="text/xml">
<cfoutput>#xml#</cfoutput>

In the types argument passed to the oSiteMap object you have a list of types. The sitemap generator will then add all of those type into the sitemap

You then point google sitemaps to this url e.g http://www.mysite.com/dmNavigation/sitemap. Notice the <!--- @@fuAlias: sitemap ---> in the code ubove, this allows me to use 'sitemap' in the url instead of the displaypage

The sitemap generator will also generate a news sitemap.

./webskins/yafNews/displayTypeSiteMap.cfm
<!--- @@fuAlias: sitemap --->
<cfset oSiteMap=createObject('component', 'farcry.core.packages.googleSiteMap.sitemap').init()>
<cfset stSiteConfig=structNew()>
<cfset stSiteConfig.domainName="#cgi.server_name#">

<cfset stSiteConfig.newspublication="#application.fapi.getConfig('general','sitetitle', '#application.applicationname#')#">

<cfset xml=oSiteMap.generate(stSiteConfig=stSiteConfig,siteMapType="newsSiteMap",newsTypes="yafNews:publishDate")>

<CFHEADER NAME="content-disposition" VALUE="inline; filename=#url.type#.#now()#">
<cfheader name="Content-Type" value="text/xml">
<cfoutput>#xml#</cfoutput>

In the newsTypes argument passed to the oSiteMap you can pass in a list of types but you must also pass in the name of the property for publishdate.

You then point google sitemaps to this url e.g http://www.mysite.com/yafNews/sitemap

The sitemap generator also deals with sitemap indexes but more on that later

  • No labels