Currently search-result.tpl.php shows:
/* ...
* Default keys within $info_split:
* - $info_split['type']: Node type (or item type string supplied by module).
* - $info_split['user']: Author of the node linked to users profile. Depends
* on permission.
* - $info_split['date']: Last update of the node. Short formatted.
* - $info_split['comment']: Number of comments output as "% comments", %
* being the count. Depends on comment.module.
*/
This was valid for Drupal 6 (http://api.drupal.org/api/drupal/modules!search!search.pages.inc/6):
$info = array();
if (!empty($result['type'])) {
$info['type'] = check_plain($result['type']);
}
if (!empty($result['user'])) {
$info['user'] = $result['user'];
}
if (!empty($result['date'])) {
$info['date'] = format_date($result['date'], 'small');
}
if (isset($result['extra']) && is_array($result['extra'])) {
$info = array_merge($info, $result['extra']);
}
However, Drupal 7 does not have $info['type'], but does have $info['module'] (see http://api.drupal.org/api/drupal/modules!search!search.pages.inc/7):
$info = array();
if (!empty($result['module'])) {
$info['module'] = check_plain($result['module']);
}
if (!empty($result['user'])) {
$info['user'] = $result['user'];
}
if (!empty($result['date'])) {
$info['date'] = format_date($result['date'], 'short');
}
if (isset($result['extra']) && is_array($result['extra'])) {
$info = array_merge($info, $result['extra']);
}
I'd write a patch, but I'm not particularly certain what $info['module'] is to be honest so wasn't sure what to put!
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 1517032-2.patch | 607 bytes | damiankloip |
Comments
Comment #1
rooby commentedThis might be worth mentioning in the Converting 6.x modules to 7.x page too as I have seen a few of modules & themes around the place having errors in drupal 7 because they are expecting $info['type'] to be there.
Comment #2
damiankloip commentedMaybe something like this will suffice?
Comment #3
rooby commentedSounds OK to me.
Comment #4
pasqualleThis is still wrong.
api.d.o: template_preprocess_search_result()
api.d.o: search-result.tpl.php
Comment #5
jhodgdonThanks! Yes, this patch was missed (there was not an actual maintainer for the Search module for quite a while there). This is fine. The documentation is also incorrect for 8.x, so technically we should fix it there first before doing a 7.x patch. However:
#1926344: Consolidate search-result.html.twig and search-results.html.twig
so I think we can just do this in 7.x.
Comment #6
jhodgdonCommitted to 7.x. Thanks again!
Comment #6.0
jhodgdonMaking PHP syntax highlighting work better on the comment code