2012-07-18, 05:26:32
Sorry to bother you on this mvlcek, but how do you use the return_search_results() function properly to access the contents of the array? Just as an example:
How would I access the contents of the page fields? I initially thought I could loop through the elements using a foreach function like so:
But this firstly doesn't print any results and secondly breaks the HTML that comes right afterwards (so the HTML of the page ends once it reaches the piece of code). What confuses me the most is the use of the I18nSearchResultPage Object () within the array. Is the use of the Object stopping me from accessing the elements of its array?
I'm asking this because I think I know how I can automate the archiving function that I worked on before (negating the need to put the '_archive' tag in posts), along with perhaps a 'display categories' function, but these can only be achieved if I can get the field information from returning the search results.
Code:
$array = Array
(
[totalCount] => 4
[first] => 0
[results] => Array
(
[0] => I18nSearchResultPage Object
(
[data:protected] =>
[tags:protected] =>
[title:protected] =>
[content:protected] =>
[id:I18nSearchResultItem:private] => news-20120715-1617
[language:I18nSearchResultItem:private] => en
[creDate:I18nSearchResultItem:private] => 1342369067
[pubDate:I18nSearchResultItem:private] => 1342369067
[score:I18nSearchResultItem:private] => 1
)
[1] => I18nSearchResultPage Object
(
[data:protected] =>
[tags:protected] =>
[title:protected] =>
[content:protected] =>
[id:I18nSearchResultItem:private] => news-20120710-0941
[language:I18nSearchResultItem:private] => en
[creDate:I18nSearchResultItem:private] => 1341913330
[pubDate:I18nSearchResultItem:private] => 1342365714
[score:I18nSearchResultItem:private] => 1
)
[2] => I18nSearchResultPage Object
(
[data:protected] =>
[tags:protected] =>
[title:protected] =>
[content:protected] =>
[id:I18nSearchResultItem:private] => news-20120710-0835-1
[language:I18nSearchResultItem:private] => en
[creDate:I18nSearchResultItem:private] => 1341909328
[pubDate:I18nSearchResultItem:private] => 1342366336
[score:I18nSearchResultItem:private] => 1
)
[3] => I18nSearchResultPage Object
(
[data:protected] =>
[tags:protected] =>
[title:protected] =>
[content:protected] =>
[id:I18nSearchResultItem:private] => news-20120710-0835
[language:I18nSearchResultItem:private] => en
[creDate:I18nSearchResultItem:private] => 1341909308
[pubDate:I18nSearchResultItem:private] => 1342365687
[score:I18nSearchResultItem:private] => 1
)
)
)
Code:
$results = $array['results'];
foreach ($results as $key => $field) {
echo 'Field: '.$field['field_name'];
}
But this firstly doesn't print any results and secondly breaks the HTML that comes right afterwards (so the HTML of the page ends once it reaches the piece of code). What confuses me the most is the use of the I18nSearchResultPage Object () within the array. Is the use of the Object stopping me from accessing the elements of its array?
I'm asking this because I think I know how I can automate the archiving function that I worked on before (negating the need to put the '_archive' tag in posts), along with perhaps a 'display categories' function, but these can only be achieved if I can get the field information from returning the search results.