Overview
Excerpt |
---|
Sitemaps facility in farcry lets you dynamically create a google sitemap with just a few lines of code. |
Navigation Sitemap
Your classic Google Sitemap should encapsulate all the navigation points in your information hierarchy. For that we need to generate an extract of the Navigation Folders (aka dmNavigation content type).
Tip |
---|
In FarCry terms, anything that is essentially a list of content items of a certain type should be built as a "type webskin" (aka listing view) of the principle content type. |
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.
Code Block | ||
---|---|---|
| ||
<!--- @@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> |
Tip | ||
---|---|---|
| ||
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 Google to this url e.g http://www.mysite.com/dmNavigation/sitemap. Notice the <!--- @@fuAlias: sitemap ---> in the code uboveabove, this allows me you to use 'sitemap' in the url instead of the displaypagefull name of the view (ie. displayTypeSiteMap).
News Sitemap
The sitemap generator will also generate a "news sitemap". Google have a special format for organisations that put out regular news-like content, and with a slight modification you can generate this type of sitemap as well.
Code Block | ||
---|---|---|
| ||
<!--- @@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="yafNewsdmNews:publishDate")> <CFHEADER NAME="content-disposition" VALUE="inline; filename=#url.type#.#now()#"> <cfheader name="Content-Type" value="text/xml"> <cfoutput>#xml#</cfoutput> |
...
You then point google sitemaps to this url e.g http://www.mysite.com/yafNewsdmnews/sitemap
Other Options
You can also overwrite the default method of getting the data by adding getSiteMapData or getNewsSiteMapData method in your type
...