Skip to content

Instantly share code, notes, and snippets.

@tao-s
Last active August 29, 2015 13:57
Show Gist options
  • Save tao-s/9742395 to your computer and use it in GitHub Desktop.
Save tao-s/9742395 to your computer and use it in GitHub Desktop.
A sample block view file for concrete5 add-on "Data".
<?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