Skip to content
Sitemason - Build on Us

SMItem Class Reference

Methods

getAccess

(string) getAccess ()
"public", "private", or "protected"
6.0.13

Information

Returns the Access setting as defined in Sitemason's administration interface.

getAlternateSource

(string) getAlternateSource ()
The alternate source
6.0

Information

Returns the "alternate source" (or "Source/Outlet Name") value as defined in the Item's Details tab.

getAlternateSourceURL

(string) getAlternateSourceURL()
The alternate source URL
6.0

Information

Returns the Alternate Source URL ("Source / Outlet URL") as defined in the Item's Details panel.

getAlternateURL

(string) getAlternateURL ()
The alternate URL value
6.0

Information

Returns the "Alternate URL" (or "Article URL") value as defined in the Item's Details tab.

getAuthorEmailAddress

(string) getAuthorEmailAddress ()
A string (email address)
6.0

Information

Returns the value for the "Author Email Address" property.

getAuthorName

(string) getAuthorName ()
The author's name (string)
6.0

Information

Returns the Author Name property's value.

getBody

(string) getBody ()
The body of the Item
6.0

Information

Returns the body field of the Item.  This is generally a lengthy string of HTML.

getCreationTimestamp

(string) getCreationTimestamp ()
A timestamp (string)
6.0

Information

Returns the timestamp of when the Item was created in the following format:

YYYY-MM-DD HH:II:SS±HH

getCurrentQuantity

(int) getCurrentQuantity()
The current quantity on hand
6.0.9

Information

Returns the current quantity of the product (SMItem) on hand, as indicated in the Sitemason interface.  Generally this is only used when shouldTrackQuantity is enabled.

getCustomFieldWithKey

(string) getCustomFieldWithKey (string)
The custom field's key
The custom field's value
6.0

Information

Returns the Custom Field value for the given key.  For "Multi Row" interface items, this key will be a string.   For Sitemason 4/5 Custom Fields, simply pass an integer (which will be internally converted to a string) from 1-16 to retrieve the corresponding Custom Field. 

The Boilerplate template makes use of custom fields (with the key "vicePresidents") in conjunction with the interface's MultiRow content item.

getEncodedTitle

(string) getEncodedTitle ()
A URL-friendly version of the Title property
6.0.3

Information

Returns the "encoded title" property, as defined by Sitemason.  This is an auto-generated, URL-friendly version of the title property.  It also includes the Item's ID, ensuring that the encoded title is unique to the Tool, even in the event that multiple Items share a title.

getEndTimestamp

(string) getEndTimestamp ()
A timestamp (string)
6.0

Information

Returns the Item's end timestamp in the following format:

YYYY-MM-DD HH:II:SS

getFile

(SMFile) getFile ()
An SMFile object
6.0.3

Information

Returns the file (SMFile object) associated with the Item.

getFiles

(array) getFiles ()
An array of SMFile objects
6.0

Information

Returns an array containing all of the SMFile objects associated with the Item.

getFormattedPrice

(string) getFormattedPrice (string)
The currency to use
The Item's price, formatted for the given currency
6.0.6

Information

Returns the Item's price as a string (formatted for the given currency).  Accepted currencies are:

  • USD: United States Dollar (default)
  • GBP: Pound sterling
  • EUR: Euro

Also, instead of one of the above three ISO currency codes, this method will accept the currency symbol that you wish to use.  Typically decimal HTML entities provide the most consistent results. 

 

For the non-formatted price, see getPrice().  If you're entering a manual currency symbol as the parameter, enter it as an HTML entity (decimal).

	$price = $item->getPrice();
echo $price;
// 2

$price = $item->getFormattedPrice();
echo $price;
// $2.00

$price = $item->getFormattedPrice('GBP');
echo $price;
// £2.00

$price = $item->getFormattedPrice('¥');
echo $price;
// ¥2.00;

$price = $item->getFormattedPrice('FK£');
echo $price;
// FK£2.00;	

getImage

(SMImage) getImage ()
An SMImage object
6.0

Information

Returns the first SMImage object belonging to the Item (if one is defined).

	

$image = $myItem->getImage();
$thumbnail = $image->getImageSizeWithKey('thumbnail');

$src = $thumbnail->getURL();
$width = $thumbnail->getWidth();
$height = $thumbnail->getHeight();
$title = $image->getTitle();

echo '<img src="'. $src .'" title="'. $title .'">';

getLargeImageSize

(SMImageSize) getLargeImageSize ()
An SMImageSize object for the "large" image
6.0

Information

Returns an SMImageSize object representing the "large" image, as defined in the Item.

	$large = $tool->getLargeImageSize();
echo '<img src="'. $large->getURL() .'" title="'. $large->getTitle() .'" />';	

getLastModifiedTimestamp

(string) getLastModifiedTimestamp ()
A timestamp (string)
6.0

Information

Returns the timestamp of when the Item was last modified in the following format:

YYYY-MM-DD HH:II:SS±HH

getLocation

(SMLocation) getLocation ()
An SMLocation object
6.0

Information

Returns the SMLocation object for the Item (if a location was defined).

	// print out the city property of the Item's location
$location = $item->getLocation();
echo $location->getCity();
	

getMaximumQuantityAllowedInCart

(int) getMaximumQuantityAllowedInCart ()
The maximum quantity allowed per order
6.0.6

Information

Returns an integer representing the maximum quantity of the item that the user is allowed to order (per order).

getMetaDescription

(string) getMetaDescription ()
The meta description string, if entered
6.0.16

Information

Returns the SMItem-level meta description property.

getMetaKeywords

(string) getMetaKeywords ()
The meta keywords property
6.0.16

Information

Returns the SMItem-level meta keywords property.

getMinimumQuantityAllowedInCart

(int) getMinimumQuantityAllowedInCart ()
The minimum quantity of the item per order
6.0.6

Information

Returns an integer representing the minimum quantity of the item that the user is allowed to order (per order).

getNextItem

(SMItem) getNextItem ()
An SMItem object
6.0

Information

Returns the next SMItem in the parent Tool's array (according to the sort order in the Tool).  Returns null if no next Item exists.

This method is useful for pagination purposes.

getPreviousItem

(SMItem) getPreviousItem ()
An SMItem object
6.0

Information

Returns the previous SMItem in the parent Tool's array (according to the sort order in the Tool).  Returns null if no previous Item exists.

This method is useful for pagination purposes.

getPrice

(float) getPrice ()
The price of the Item
6.0.6

Information

Returns the price of the Item, as defined in Sitemason.

This method returns the raw price (as a float).  If you want a formatted price (i.e. "$12.95"), look at getFormattedPrice().

getProductAttributes

(string) getProductAttributes()
The product attributes
6.0.9

Information

Return the product attributes string, which while flexible (it is solely defined within the Sitemason interface by the administrator), is intended to be formatted according to FoxyCart's product attribute scheme.

getProductAvailabilityMessage

(string) getProductAvailabilityMessage()
The product availability message
6.0.9

Information

Returns the product availability message, which is defined in Sitemason for the product (SMItem).  While this can be used for any purpose at hand, it is intended to be used when shouldTrackQuantity is enabled and there are no products remaining in inventory (currentQuantity is zero).

	if ($myWidget->shouldTrackQuantity() && $myWidget->getCurrentQuantity() == 0) {
  echo $myWidget->getProductAvailablityMessage();
  // prints something along the lines of, "Sorry, we're out!"
}	

getProductCode

(string) getProductCode ()
The Item's Product Code
6.0.6

Information

Returns the Product Code for the Item, as set in the Sitemason administration interface.

getSequence

(int) getSequence ()
The number of times the Item has been updated
6.0.10

Information

Returns an integer representing the number of times this Item has been updated.

getShippingAndDiscountCategory

(string) getShippingAndDiscountCategory ()
The shipping/discount category
6.0.6

Information

Returns the Shipping/Discount Category as defined in the Sitemason administration interface.

getStartTimestamp

(string) getStartTimestamp ()
A timestamp (string)
6.0

Information

Returns the Item's start timestamp in the following format:

YYYY-MM-DD HH:II:SS

getSubtitle

(string) getSubtitle ()
The Item's subtitle property
6.0

Information

Returns the subtitle property for the Item.

getSummary

(string) getSummary ()
The Item's summary
6.0

Information

Returns the Item's summary value.

getTags

(array) getTags ()
An array of SMTag objects
6.0

Information

Returns an array of all Tags (SMTags) associated with this Item.

getTagsInTagGroupWithTitle

(array) getTagsInTagGroupWithTitle (string)
The title of a Tag Group
An array of SMTag objects
6.0

Information

Returns an array of Tags (SMTag objects) representing the subset of Tags contained within a Tag Group (the Tag Group with the given title) that are associated with the Item.

getThumbnailImageSize

(SMImageSize) getThumbnailImageSize ()
An SMImageSize object
6.0

Information

Returns the SMImageSize object representing the Thumbnail image as defined in the Item.

	$thumb = $tool->getThumbnailImageSize();
echo '<img src="'. $thumb->getURL() .'" title="'. $thumb->getTitle() .'" />';	

getTitle

(string) getTitle ()
A string
6.0

Information

Returns the "title" property of the Item.

getTitlesOfTags

(array) getTitlesOfTags ()
A array of strings
6.0

Information

Returns an array of the title properties for each Tag assigned to the Item.

getTitlesOfTagsInTagGroupWithTitle

(array) getTitlesOfTagsInTagGroupWithTitle (string)
The "title" property of the Tag Group to query
An array of strings (Tag titles)
6.0

Information

This method is useful if you're looking for only the titles of the Tags assigned to this Item that are also in a given Tag Group (as opposed to full SMTag objects, which is what is returned by the getTagsInTagGroupWithTitle() method).

getTool

(SMTool) getTool()
An SMTool object
6.0

Information

Returns the tool (SMTool object) that this Item belongs to.

getURL

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

Information

Returns the URL of the Item within the website.  This URL will technically be the URL for this Item, presented within the detail view of the Item's Tool.

getWeight

(float or integer) getWeight ()
The weight of the item
6.0.6

Information

Returns the weight of the Item as a number (float or integer), as defined in the Sitemason administration interface.

getWindowTitle

(string) getWindowTitle ()
A string
6.0

Information

Returns the Window Title property data, as defined in the Tool's Settings panel.

	

$title = $smCurrentTool->getWindowTitle();
echo '<title>'. $title .'</title>';

hasTagWithTitle

(bool) hasTagWithTitle ()
A boolean
6.0

Information

Returns true/false depending on whether or not the Item contains a tag (SMTag) with the given title (the Tag's "title" property matches the given string).

isApproved

(boolean) isApproved ()
true or false
6.0.13

Information

Returns true or false depending on whether or not the Item is approved for publication (rather than "pending").  Note: this method is only useful if you're working with Items retrieved from an API query, as all Items present within a website are, by default, approved (or else they would not be part of any Tool's Items set).

isImportant

(bool) isImportant ()
A boolean
6.0

Information

Returns true/false based on whether or not the Item has been flagged as important, which is simply a flexible flag used for any purpose the website implementation might need.

isLead

(bool) isLead ()
A boolean
6.0

Information

Returns true/false depending on whether or not the Item has been flagged as a "Lead Item," which is simply a flexible flag used for implementation purposes.

isLive

(boolean) isLive ()
true or false
6.0.13

Information

Returns true or false depending on whether or not the Item is live.  Note: this method is only useful if you're working with Items retrieved from an API query, as all Items present within a website are live (or else they would not be part of any Tool's Items set).

setLocations

(void) setLocations (array)
An array of SMLocation object(s)
6.0.10

Information

Sets the Item's locations to the given value(s).  Note that while the Sitemason 6.0 interface and application support only one time per Item, future versions will support multiple times, hence why the parameter should be an array.

setTimes

(void) setTimes (array)
An array of SMTime objects
6.0.3

Information

Sets the Item's times to the given value(s).  Note that while the Sitemason 6.0 interface and application support only one time per Item, future versions will support multiple times, hence why the parameter should be an array.

	$timeParams = array('startTime' => '2013-08-14 09:00', 'endTime' => 2013-08-14 09:00);
$newSMTime = new SMTime($timeParams);
$myItem->setTimes(array($newSMTime));	

shouldPreventBackorder

(bool) shouldPreventBackorder()
True or False
6.0.9

Information

Returns a boolean depending on whether the Should Prevent Backorder option is selected for the Product (SMItem).

shouldTrackQuantity

(bool) shouldTrackQuantity()
True or False
6.0.9

Information

Returns true or false, depending on whether the Should Track Quantity option is selected for this product (SMItem).