This is the API docs for LemonStand V1, which has been discontinued. LemonStand is now a cloud based platform, available at lemonstand.com.

LemonStand API

Db_Act_As_Tree class

Defined in /phproad/modules/db/classes/db_act_as_tree.php, lines 13-278
Inheritance Phpr_Extension » Db_Act_As_Tree
Author LemonStand eCommerce Inc.
Allows to extend models with tree functionality. Any Db_ActiveRecord descendant can be extended with this class. To extend a model class add this class name to the model's implement property. Example:
public $implement = 'Db_Act_As_Tree';

Public properties

Property Type Description Defined By
act_as_tree_parent_key string specifies a database column which contains a reference to a parent record. Db_Act_As_Tree

Public methods

Method Description Defined By
get_parent() returns a parent record. Db_Act_As_Tree
get_parents() returns a list of parent records. Db_Act_As_Tree
list_children() returns a list of children records. Db_Act_As_Tree
list_root_children() returns a list of root records. Db_Act_As_Tree

Property details

act_as_tree_parent_key property

public string $act_as_tree_parent_key;
Specifies a database column which contains a reference to a parent record. Default value of this property is parent_id, but it can be overridden in the extended model.

Method details

get_parent() method

public Db_ActiveRecord get_parent(string $order_by='name')
$order_by string specifies a database column name to sort the items by. Due to the performance considerations the parameter value should match the value you use for list_all_children_recursive() and list_children() methods.
{return} Db_ActiveRecord returns the parent model or NULL if the parent record is not found or the method is called for a root record.
Returns a parent record.

get_parents() method

public array get_parents(boolean $include_this=false, $order_by='name')
$include_this boolean determines whether the current model should be included to the list.
$order_by
{return} array returns an array of parent records.
Returns a list of parent records. You can use this method for displaying a path to a category, for example on the product page, in the following format: Category: Crafts, Stationery and more » Art. Code example:
<p>Category:    
  <?
    $categories = $product->category_list[0]->get_parents(true);
    $cnt = count($categories);
    foreach ($categories as $index=>$category):
  ?>
    <a href="<?= $category->page_url('/category') ?>"><?= h($category->name) ?></a>
    <? if ($index < $cnt-1) echo "»" ?>
  <? endforeach ?>
</p>

list_children() method

public Db_DataCollection list_children(string $order_by='name')
$order_by string specifies a database column name to sort the items by.
{return} Db_DataCollection returns a collection of children records.
Returns a list of children records. Usage example:
$subcategories = $category->list_children('front_end_sort_order');

list_root_children() method

public Db_DataCollection list_root_children(string $order_by='name')
$order_by string specifies a database column name to sort the items by.
{return} Db_DataCollection returns a collection of root records.
Returns a list of root records. Usage example:
$root_categories = Shop_Category::create()->list_root_children('front_end_sort_order');