English English Spanish EspañolKorea한국어
Straker»Company»Blog»2007» Creating a ShadoCMS Site Map

Creating a ShadoCMS Site Map

This came up today on the mailing list so I thought we should do a quick blog on the subject.

The easiest way to create a site map is to use the shado_tree_objects.cfc which lives in shadomx\ui\menus\. The code below will generate a site map for your site when included in a template. As you can see you can pass in a list of object (page or section) names and/or a list of page or section UUID's to exclude from the site map. We do this as the shado_tree_objects component will not filter objects based on permissions so you need to explicitly do this here. 

 

<cfset pathToFolderIcon = "/shadomx/ui/pics/icons/folder.gif">
    <cfset pathToPageIcon ="/shadomx/ui/pics/icons/page.gif">
    <cfset objectExcludeList = "System Pages,Recycle Bin" >
   
    <cfset excludeUUIDList ="" >

        <cfscript>
       
            force = false;
           
            // initiate the cached menu object
            oSection =  application.shado_obj_factory.get("shado_obj_sections");
            rootSection = application.shado_obj_factory.get("shado_obj_sections").getRootSection().uuid;
            request.menuObj            = application.shado_obj_factory.get("shado_tree_objects").init(force=force);
            // get the info about the current page
            //currentPage             = request.menuObj.getObject(obj_uuid=request.getPageObject.page_uuid);
            //currentCrumbs             = currentPage.value.obj_crumbs.struct;
            // get the site tree (refresh every request when logged in else grab it from the cache)
            nav                     = request.menuObj.getQuery(quickRefresh=request.userContext.loggedIn);
        </cfscript>

<cfoutput>   
   
                   
                <table width="774" border="0" cellspacing="0" cellpadding="0" id="shadomx_sitemap">
                    <tr>
                        <td width="100%" class="content" valign="top">
                            <table cellspacing="0" border="0">

                                <tr>
                                    <td class="content"><cfset spacer = '<img src="/#request.siteContext.dsn#/pics/spacer.gif" width="25" height="1" alt="" border="0">'>
                                        <table border="0" cellspacing="0" cellpadding="0">
                       
                                        <cfloop query="nav">
                                        <cfif not listfindnocase(objectExcludeList,obj_title) and not listfindnocase(excludeUUIDList,obj_crumbs_uuid) and  OBJ_ACTIVE is 1 >
                                                <cfif obj_type eq "section" >
                                                    <tr>
                                                        <td>
                                                            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                                                <tr valign="middle">
                                                                    <cfloop index="idx" from="1" to="#obj_depth#">
                                                                        <td width="25">    #spacer#</td>
                                                                    </cfloop>
                                                                    <td><a class="project" href="/#request.sitecontext.dsn#/#obj_homepage_ssurl#"><img src="#pathToFolderIcon#" width="20" height="18" alt="" border="0"></a></td>
                                                                    <td width="100%"><a class="sidemenu_item" href="/#request.sitecontext.dsn#/#obj_homepage_ssurl#">#obj_title#</a>                                                    </td>
                                                                </tr>
                                                            </table>
                                                        </td>
                                                    </tr>
                                                    <cfelse>
                                                    <cfset qSection = application.shado_obj_factory.get("shado_obj_sections").get(uuid=OBJ_PARENT_UUID,selectFields="circuit_active")>
                                                   
                                                            <cfif qSection.circuit_active is 1>
                                                                <tr>
                                                                    <td>
                                                                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                                                            <tr valign="middle">
                                                                                <cfloop index="idx" from="1" to="#obj_depth#">
                                                                                    <td width="10">    #spacer#</td>
                                                                                </cfloop>
                                                                                <td><a href="/#request.sitecontext.dsn#/#obj_homepage_ssurl#"><img src="#pathToPageIcon#" width="17" height="19" alt="" border="0"></a></td>
                                                                                <td width="100%"><a class="sidemenu_item" href="/#request.sitecontext.dsn#/#obj_ssurl#">#obj_title#</a></td>
                                                                            </tr>
                                                                        </table>
                                                                    </td>
                                                                </tr>
                                                            </cfif>
                                                    </cfif>
                                            <cfelse>
                                        </cfif>
                                        </cfloop>
                                        </table>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
                

 

 Caching

The shado_tree_objects can be a resource heavy component if you have a large site so your best option is to cache the rendered site map html and not call the component on each request. If you are calling the site map as a pagelet then this would be done automatically if the pagelet cache is set to yes, otherwise use the variables cache to roll your own simple cache.

 


Comments

There are no comments for this page as yet.

Add a comment