Skip to content
Sitemason - Build on Us

SMFolder Class Reference

Overview

SMFolder contains information relating to a particular Folder of the website.  SMFolders contain Tools (SMTools) and possibly other Folders (SMFolders) with another layer of Tools (and potentially more Folders).

In fact, the entire website itself is a Folder ($smCurrentSite or the "root folder") and, in the case where a website has only one level of navigation, $smCurrentFolder and $smCurrentSite are the same object.

Methods

getCopyright

(string) getCopyright ()
The copyright setting's data
6.0

Information

Returns the copyright data, as set in the Folder's settings panel.

getFolder

(SMFolder) getFolder ()
An SMFolder object or null
6.0

Information

Essentially identical to SMTool's getFolder method, this getFolder() method returns the SMFolder object for the Folder's parent Folder, if applicable.  getFolder() will returns null if no parent Folder exists (the case where the SMFolder is the root Folder, or $smCurrentSite).

getFooter

(string) getFooter ()
The footer setting's data
6.0

Information

Returns the footer data, as set in the Folder's settings panel.

getFullPath

(string) getFullPath ()
The full path for the Folder

Information

Returns the full path for the Folder, based on the root of the website.

getGoogleAnalyticsID

(string) getGoogleAnalyticsID ()
The Google Analytics ID
6.0

Information

Returns the Google Analytics ID data, as set in the Folder's settings panel.

getGoogleVerificationCode

(string) getGoogleVerificationCode ()
The Google Verification Code setting's value
6.0

Information

Returns the Google Verification Code, as set in the Folder's settings panel.

getMetaDescription

(string) getMetaDescription ()
The Meta Description setting's data
6.0

Information

Returns the meta description data, as set in the Folder's settings panel.

getMetaKeywords

(string) getMetaKeywords ()
The Meta Keywords setting's data
6.0

Information

Returns the meta keywords data, as set in the Folder's settings panel.

getNavigationTools

(array) getNavigationTools ()
An array of SMTool (and SMFolder) objects
6.0

Information

Returns an array of the tools (SMTools and children SMFolders, if applicable) in the given Folder.  This method is essentially the same as getTools() except where as getTools() contains the entire hierarchy of all SMTool and SMFolder objects in the given Folder, getNavigtationTools() includes only the SMTool and SMFolder objects that have the "Include in Navigation" option (in the Settings panel) set to true.

This method is generally called from $smCurrentSite and/or $smCurrentFolder.  Here is a typical scenario:

A website has a two-level hierarchy: the first level ($smCurrentSite) includes a Folder for the "About Us" section with two pages inside that folder: "About" and "Contact Us".  This website has primary navigation in the header (containing the pages at the first level) and, when the user is visiting something in the "About Us" section, second-level navigation in the left callout.  In this scenario, you'd call $smCurrentSite->getNavigationTools() to create the primary navigation.  When the user is in a subfolder (like the "About Us" section, where $smCurrentFolder is the "About Us" Folder), you would call $smCurrentFolder->getNavigationTools() to create the secondary navigation for the About Us section's left callout.

	$tools = $smCurrentSite->getNavigationTools();
/*
Note: $tool could be either an SMTool or SMFolder object, but the following methods 
critical  to navigation work with  both objects.
*/

// print out a list with the top-level navigation
echo '<ul>';
foreach ($tools as $tool) {
    echo '<li>';
    echo '	<a href="'. $tool->getPath() .'">'. $tool->getTitle() .'</a>';
    echo '</li>';
}
echo '</ul>';	

getNextNavigationTool

(SMTool) getNextNavigationTool (bool)
An optional boolean to enable looping
An SMTool object
6.0

Information

This method is intended to provide a means to paginate through Tools within your website.  GetNextNavigationTool() takes the results of the Folder's getNavigationTools() method and flattens the resulting array (removes any child Folders and merges those Folders' Tools into the array, creating a one-level array of all Tools in the Folder and child Folders).  It then iterates through the array and attempts to find a Tool that matches $smCurrentTool (the Tool being currently-viewed by the site visitor).  If a match is found and there are additional Tools in the array, the next element will be returned.

By default, getNextNavigationTool does not loop, so if $smCurrentTool is the last tool in the flattened navigation array, null will be returned.  By passing this method "true," looping will be enabled.  In this case, the scenario just described will return the first Tool in the array.

getNextNavigationTool() can be called on any Folder, depending on how you wish to use it.  $smCurrentSite->getNextNavigationTool() would compare $smCurrentTool against all Tools in your website, while $smCurrentFolder->getNextNavigationTool() would compare $smCurrentTool against all Tools in the currently-viewed Folder (which could be the entire site, but is not necessarily so).

getPreviousNavigationTool

(SMTool) getPreviousNavigationTool (bool)
An optional boolean to enable looping
An SMTool object
6.0

Information

This method is intended to provide a means to paginate through Tools within your website.  GetPreviousNavigationTool() takes the results of the Folder's getNavigationTools() method and flattens the resulting array (removes any child Folders and merges those Folders' Tools into the array, creating a one-level array of all Tools in the Folder and child Folders).  It then iterates through the array and attempts to find a Tool that matches $smCurrentTool (the Tool being currently-viewed by the site visitor).  If a match is found and the pointer does not point to the first Tool in the array ($smCurrentTool is not the first tool in the flattened navigation array), the previous element will be returned.

By default, getPreviousNavigationTool does not loop, so if $smCurrentTool is the first tool in the flattened navigation array, null will be returned, because there is no previous Tool.  By passing this method "true," looping will be enabled.  In this case, the scenario just described will return the last Tool in the array.

getPreviousNavigationTool() can be called on any Folder, depending on how you wish to use it.  $smCurrentSite->getPreviousNavigationTool() would compare $smCurrentTool against all Tools in your website, while $smCurrentFolder->getPreviousNavigationTool() would compare $smCurrentTool against all Tools in the currently-viewed Folder (which could be the entire site, but is not necessarily so).

getTitle

(string) getTitle ()
The SMFolder's title property
6.0

Information

Returns the title property for the SMFolder, as defined in the Folder's Settings panel.

getTools

(array) getTools ()
An array of SMTool and SMFolder objects
6.0

Information

Returns an array of Tools (and potentially Folders) belonging to this Folder.  On a one-level site, calling getTools() will only return an array of SMTool objects.  On a hierarchically-organized site with subsections (represented by Folders), calling getTools() will return an array of SMTool objects and SMFolder objects, with each SMFolder object containing its own set of Tools accessible by its getTools() method.

getToolType

(string) getToolType ()
"folder"
6.0

Information

Just like SMTool's getToolType() method, it returns the type of the Tool.  Though unlike SMTool's getToolType, SMFolder's variant will always return "folder."

getToolWithSlug

(SMTool) getToolWithSlug (string)
A Tool's "slug" property
An SMTool object
6.0

Information

Returns the SMTool object for the Tool with the given slug.  Slugs are unique strings used to identify a Tool in your site.  getToolWithSlug() is used primarily as a means to quickly access a Tools' data for use with page callouts.

	

/*
Suppose that you want to list the most-recent 5 news articles from your news page (News tool with the slug "news") on your home page.
*/

$newsCallout = $smCurrentSite->getToolWithSlug('news');
$newsArticles = $newsCallout->getItemsWithLimitAndOffset(5,0);

// $newsArticles is an array of SMTool objects

getURL

(string) getURL ()
The URL of the Folder
6.0

Information

Returns the URL of the Sitemason Folder.

getWindowTitle

(string) getWindowTitle ()
The window title setting
6.0

Information

Returns the "Window Title" setting, as defined in the Tool's Settings panel.

hasNavigationTools

(bool) hasNavigationTools ()
True or False
6.0.5

Information

Returns true or false, depending on whether the Folder has one or more Tools (within the Folder) that should be included in the navigation.

isCurrentlyDisplayed

(bool) isCurrentlyDisplayed ()
A boolean
6.0

Information

Returns a boolean depending on whether or not the current Folder is contained in the path (or breadcrumb trail) of the page viewed by the site visitor. Note: this property is only set as part of SMFolder's getNavigationTools() method, as it is intended for navigation purposes only.

isRootFolder

(bool) isRootFolder ()
A boolean
6.0

Information

Returns true or false depending on whether or not the SMFolder is the root folder (the site-level folder).  If true, the folder in question is the same as the SMFolder object contained in $smCurrentSite.  Another differentiation of the root folder is that the root folder will have a null value for the "folder" property (since the root folder will not have a parent folder).  However, isRootFolder() is generally an easier way to establish whether or not the folder in question is the root.

shouldIncludeInNavigation

(bool) shouldIncludeInNavigation ()
A boolean
6.0

Information

Returns true or false, depending on whether or not the folder has been designated to be included in the navigation.

shouldIncludeInSiteMap

(bool) shouldIncludeInSiteMap ()
A boolean
6.0

Information

Returns true or false, depending on whether or not the folder has been flagged for inclusion in the site map.