Can't retrieve data
This is my first attempt to display data. I've created landing.php in the About folder. When I try to run it, I get a 500 server error. I'm basically just adding an example on the API documentation. You can see the result at
http://collections.louisahistory.org/pawtucket/index.php/About/landing
The code (I omitted the HTML above the /div). The html by itself works fine--if I delete the php code, it brings up the screen.
</div>
<?php
$o_search=new ObjectSearch();
$qr_results=$o_search->search("Unknow");
// dump preferred labels in all languages
while($qr_results->nextHit()) {
print_r($qr_results->get('ca_objects.preferred_labels.name', array('returnAllLocales' => true, 'returnAsArray' => true)))";
}
?>
Comments
Hi, try with this code into your controller file:
require_once(__CA_LIB_DIR__.'/Search/ObjectSearch.php');
...code...
public function __call($ps_function, $pa_args) {
... code ...
$objects = [];
$objectSearch = new ObjectSearch();
$queryResult = $objectSearch->search("*"); // NOTE: "*" search word example: "lorem"
while($queryResult->nextHit()) {
$object = new stdClass();
$object->id = $queryResult->get('object_id');
$object->idno = $queryResult->get('idno');
$object->title = $queryResult->get('ca_objects.preferred_labels.name');
$object->img_url = $queryResult->getMediaURL('ca_object_representations.media', 'medium');
$objects[] = $object;
}
echo "<pre>";
var_dump($objects);
echo "</pre>";
exit;
... code ...
}
... code ...
I hope this will help you.
Thanks-I got this to work, but it's been so long since I posted it, I forget how I did it. I think it was because I couldn't use the name 'landing.'