Last active
August 29, 2015 13:57
-
-
Save tao-s/9742395 to your computer and use it in GitHub Desktop.
A sample block view file for concrete5 add-on "Data".
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php defined('C5_EXECUTE') or die("Access Denied."); | |
//Load Data models in package | |
Loader::model("data_list","data"); | |
Loader::model("data_type","data"); | |
//Create DataType object | |
$dataType = new DataType; | |
//load DataType by handle | |
$dataType->Load('dtHandle=?', array("object")); | |
//Create DataList object | |
$DataList = new DataList($dataType); | |
/* Filter by some attribute. | |
* $DataList->filterByAttribute("data_[object handle]_[attribute handle]", $value, '='); | |
*/ | |
$objects = $DataList->get(); | |
//list | |
foreach($objects as $object ){ | |
/* | |
$attributes = $object->getAttributeValueObjects(); | |
foreach($attributes as $attribute){ | |
echo "<p>".$attribute->getValue()."</p>"; | |
} | |
*/ | |
/* Display specific attributes. | |
* If you created "object" object and the object have "example" attribute. | |
*/ | |
echo '<p>'.$object->example->getValue("display").'</p>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment