Cookbook Chapter 4: Pawtucket/en
From CollectiveAccess Documentation
Contents
Pawtucket
Adding elements to a "detail" page
- Problem
- You want to add fields (or metadata elements) to the display on an "detail" page.
- Solution
- To place metadata elements in the left column of a detail page, set ca_objects_detail_display_attributes, ca_entities_detail_display_attributes, ca_places_detail_display_attributes, ca_occurrences_detail_display_attributes and/or ca_collections_detail_display_attributes in app.conf to a list of the element codes you would like to appear.
Adding a list element to a "detail" page
- Problem
- You want to add a list element to the display on an "detail" page.
- Solution
- You need to pass the convertCodesToDisplayText option to get() in the Detail view on your detail page (/themes/default/views/Detail). For example,
if($vs_material = $t_object->get("ca_objects.material" , array('convertCodesToDisplayText' => true))){
print "<div class='unit'><b>".$t_object->getDisplayLabel("ca_objects.material").":</b> {$vs_material}</div><!-- end unit -->";
}
Adding a relationship to a "detail" page
- Problem
- You want to display a relationship on a record's "detail" page.
- Solution
- You'll need to add the relationship(s) in the file for the specific detail page (i.e. ca_collections_detail_html.php) at themes/(your_theme)/views/Detail. Below shows Related Entities on a Collection detail page.
$va_entities = $t_collection->get("ca_entities", array("returnAsArray" => 1, 'checkAccess' =>$va_access_values)); if(sizeof($va_entities) > 0){ ?><div class="unit"><h2><?php print _t("Related")." ".((sizeof($va_entities) > 1) ? _t("Entities") : _t("Entity")); ?></h2>
<?php
foreach($va_entities as $va_entity) {print "<div>".(($this->request->config
>get('allow_detail_for_ca_entities')) ? caNavLink($this->request, $va_entity["label"], '', 'Detail', 'Entity', 'Show', array('entity_id' => $va_entity["entity_id"])) : $va_entity["label"]).(".$va_entity['relationship_typename'].")</div>\n";
}
?>
</div><!-- end unit -->
<?php
}
Adding a relationship to a "detail" page with additional metadata
- Problem
- You want to display a relationship on a record's "detail" page, but also pull metadata from the related record.
- Solution
- You'll need to add the relationship(s) in the file for the specific detail page (i.e. ca_objects_detail_html.php) at themes/(your_theme)/views/Detail, just like above. Additional syntax is required to display the related record's metadata. Below shows Related Occurrences on an object detail page, where the Occurrence Date is displayed along with the Occurrence itself. To configure metadata in your relationship bundle, swap out "Date" for the element code of the data you wish to display.
<code> get("ca_occurrences", array("returnAsArray" => 1, 'checkAccess' =>$va_access_values)); if(sizeof($va_occurrences) > 0){ ?> 1) ? _t("Occurrences") : _t("Occurrence")); ?> ".(($this->request->config->get('allow_detail_for_ca_occurrences')) ? caNavLink($this->request, $va_occurrence["label"], '', 'Detail', 'Occurrence', 'Show', array('occurrence_id' => $vn_occurrence_id)) : $va_occurrence["label"])." (".$va_occurrence['relationship_typename'].") \n"; print " "._t("Occurrence Date").": ".$t_occurrence->get('ca_occurrences.DATE')." "; } ?></code>
i_sphinx