Hello,
The Theme pref doesn't have option to stop Post Info showing up on search result. How do I stop this? I am on Garland, by the way.
Any help would be appreciated.
Hi,
I don't think there's an admin settings page or module to do it, but you can quickly override themes_search_item: http://api.drupal.org/api/5/function/theme_search_item
HTH
s
Sat, 26 May 2007 03:06:40 -0400 -n "A-NO-NE Music" madflute@anonemusic.com írta:
Hello,
The Theme pref doesn't have option to stop Post Info showing up on search result. How do I stop this? I am on Garland, by the way.
Any help would be appreciated.
sessy / 2007/05/26 / 05:23 AM wrote:
I don't think there's an admin settings page or module to do it, but you can quickly override themes_search_item: http://api.drupal.org/api/5/function/theme_search_item
Nice! Thank you!
Well, commenting out a few lines made it work as I wanted, but I don't exactly know what I am doing.
($item['snippet'] ? '<p>'. $item['snippet'] . '</p>' : '')
Why this way, is way beyond my PHP knowledge. But I hope I should see obvious error if my modification was bad, and since I see the result as expected, I am doing OK, yes?
On Saturday 26 May 2007 00:46:17 A-NO-NE Music wrote:
sessy / 2007/05/26 / 05:23 AM wrote:
I don't think there's an admin settings page or module to do it, but you can quickly override themes_search_item: http://api.drupal.org/api/5/function/theme_search_item
Nice! Thank you!
Well, commenting out a few lines made it work as I wanted, but I don't exactly know what I am doing.
($item['snippet'] ? '<p>'. $item['snippet'] . '</p>' : '')Why this way, is way beyond my PHP knowledge. But I hope I should see obvious error if my modification was bad, and since I see the result as expected, I am doing OK, yes?
This is what sessy meant: http://drupal.org/node/11811 http://drupal.org/node/55126
While it will be more work and effort to do so, it will be better in the long run to override the function rather than to modify the core code. The reason being that you will end up with a problem when you go to do your upgrade to Drupal 5.2 or 6 and your changes get reverted.
Jason Flatt / 2007/05/26 / 08:35 AM wrote:
This is what sessy meant: http://drupal.org/node/11811 http://drupal.org/node/55126
Oh, I see. Thank you so much for pointing out quickly. However, I am having problem understanding this. I think this goes with my the other documentation ranting thread :-)
These documentation tells me I should find: theme_search_item() in garland\template.php but it's not there.
Or am I supposed to append: <?php function theme_search_item($items = array(), $title = NULL, $type = 'ul') { ?> to garland\template.php file?
Or am I supposed to write up: <?php function phptemplate_search_item($items = array(), $title = NULL) { return _phptemplate_callback('item_list', array('items' => $items, 'title' => $title)); } ?>
I think my problem with Drupal documentation is these details not being too clear to idiots like me :-)
I am happy to report I was able to override the function by writing phptemplate_search_item() in the template.php. However, I must wonder what I did was OK since it isn't the same as what the documentation tells me.
http://drupal.org/node/11811 This tells me I need _phptemplate_callback() but I couldn't figure out what the param should be. The example is too different, and the API list doesn't mention this in detail. I tried a few params by guesses, all which returned in PHP error.
On Saturday 26 May 2007 11:09:04 A-NO-NE Music wrote:
I am happy to report I was able to override the function by writing phptemplate_search_item() in the template.php. However, I must wonder what I did was OK since it isn't the same as what the documentation tells me.
http://drupal.org/node/11811 This tells me I need _phptemplate_callback() but I couldn't figure out what the param should be. The example is too different, and the API list doesn't mention this in detail. I tried a few params by guesses, all which returned in PHP error.
In your theme's main directory (themes/garland/, if that's what you're using, though I'd create a duplicate, rename it and modify the duplicate) create a template.php file containing the following code (or add the code to an already existing file, minus the opening <?php line):
<?php function phptemplate_search_item($item, $type) { // The following should be all on one line: return _phptemplate_callback('search_item', array('item' => $item, 'type' => $type)); }
(Note: no closing ?> is necessary.)
Then create a file called search_item.tpl.php in the same directory with the code you want used for your theming. You can use one of your existing .tpl.php files (page.tpl.php, node.tlp.php, etc.) as an example for how to format your search_item.tpl.php file, but copy the code from the search module function you're overridding as a starting point.
Though I haven't completed it yet, I was doing yesterday what you're doing today with that and the theme_search_page functions. As an example for you, here's what I have so far in my search_item.tpl.php:
<dt class="title"> <a href="<?php echo check_url($item['link']); ?>"><?php echo check_plain($item['title']); ?></a> </dt>
<?php $info = array(); if ($item['type']) { $info[] = $item['type']; } if ($item['user']) { $info[] = $item['user']; } if ($item['date']) { $info[] = format_date($item['date'], 'small'); } if (is_array($item['extra'])) { $info = array_merge($info, $item['extra']); } ?>
<dd> <?php echo ($item['snippet'] ? '<p>'. $item['snippet'] . '</p>' : ''); ?> <p class="search-info"> <?php echo (implode(' - ', $info)); ?> </p> </dd>
My goals for my customization are different than yours. For you, I would remove or comment out the part that looks like this: <p class="search-info"> <?php echo (implode(' - ', $info)); ?> </p>
(And you might as well remove all that code which fills in that $info variable.)
Jason Flatt / 2007/05/26 / 02:44 PM wrote:
My goals for my customization are different than yours. For you, I would remove or comment out the part that looks like this:
<p class="search-info"> <?php echo (implode(' - ', $info)); ?> </p>
(And you might as well remove all that code which fills in that $info variable.)
Worked great! Thank you so much for your kind assist!