I really need to have search result row styles in some of my views. I have only recently moved to D6 + Views 2 so I am still only learning the new template related changes in D6 and views 2.
BUT, this is how I got it to work without any errors.
I removed the return disabled code in search_views_plugins() in search.view.inc.
Then I created a tpl file called views-view-row-search.tpl.php and placed it in the views/theme directory.
I copied the contents of the core search-result.tpl.php. http://api.drupal.org/api/file/modules/search/search-result.tpl.php/6/so... (could also just include the core tpl file).
Cleared my cache and rescanned for template files and it worked.
Hope that helps other people and hopefully this can be in the next release.
| Comment | File | Size | Author |
|---|---|---|---|
| #25 | views-rows-style-488466-d7.patch | 8.86 KB | NaX |
| #23 | views-n488466-23.patch | 815 bytes | damienmckenna |
| #19 | views-2.x-search.patch | 5.35 KB | mikeker |
| #10 | views_search_1.patch | 5.06 KB | dawehner |
| #9 | views_search.patch | 5.05 KB | NaX |
Comments
Comment #1
dawehnerdo you want to write a patch for it?
for example for the documentation.
I think you can copy the tpl also to your theme and not to views itself
Comment #2
merlinofchaos commentedInteresting. I see that this works, and this is good, but it seems like we should be using theme('search_result') so that everything funnels into the right template. That means re-organizing things so that the data is put properly into a result array and passed through normally. And it should also use the views theme functions so that search_result__view__etc works along with everything else.
I started looking into doing this, but it's a little more work than I want to do right now, but I would welcome patches.
Comment #3
NaX commentedI don’t know about using theme('search_result') but another thing that I found is that in template_preprocess_views_view_row_search() we need to set the
$node->build_modeEG:
Comment #4
dawehnerOne quick observation:
views_view_row_search.tpl.php is missing
Comment #5
ptitb commentedThis post was very usefull for me to display the exposed filter results as search results.
I only found that the search_excerpt function didn't highlight the search terms found.
With the following alterations I was able to get this working.
Not sure if this is the best way to get this done, but I'm not a php expert.
Comment #6
ambientdrup commentedWhere is this file (search.view.inc.) mentioned at the beginning of this post? I can't locate it in Views2.
-backdrifting
Comment #7
NaX commented@ambientdrup
This is all the files you need to deal with.
views/modules/search.views.inc
views/theme/views-view-row-search.tpl.php
@ptitb
To get the snippet to work I do the following. I also don't know what the best way is.
Your way looks simpler and I am hard coding the Filter identifier.
Comment #8
esmerel commentedMarking this "needs more info"; if the full doc writeup is going to be done, great! If not, then the issue needs to get cleaned out.
Comment #9
NaX commentedThe attached patch is what works best for me after some more experimentation.
This patch does not address merlinofchaos point in #2.
Please note that normally I generate patches with winmerger but this patch was made with Kompare on Suse and it’s my first time using Kompare.
Comment #10
dawehnerHere is a version which uses theme_search_result.
Is this only true for php4?
Comment #11
NaX commented@dereine
No, that is only relevant to shared hosts that don’t give you enough memory to output view objects to screen while debugging. It can safely be removed.
Comment #12
dawehner@NaX
If you use the devel module's dpm function you can do it. At least for me it's working perfect
Comment #13
NaX commented@dereine
I was using dsm() and I was about the to ask about the difference when I saw that dsm() is now considered a legacy function. Thanks.
Comment #14
dawehnerYes, dsm is now just an alias for dpm.
Sorry for "spamming" the issue queue.
Comment #15
merlinofchaos commentedI would love it if some bug squad folks could test this patch. Code review optional but valuable, but just knowing that people have gone through the steps to make sure this does what it says it does would help me.
Comment #16
interestingaftermath commentedsubscribe - could this also be considered for 3.x?
Comment #17
dawehnerThe question is whether this will be considered for 6.x-2.x or not. :)
If you subscribe, did you tested the patch?
Comment #18
interestingaftermath commentedI did test the patch in 3.x and it seems to work if I would get the theme templates setup correctly. However, I couldn't take the risk of having to worry about keeping up with the patch as 3.x continues to be upgraded. The site I would be using this for uses views heavily and wants to be using the latest/greatest. I subscribe in hopes that someone smarter than I can upgrade this to 3.x and get it committed :)
Comment #19
mikeker commentedCorrects syntax error (missing semicolon).
I'm not "bug squad" but I'll give it a bit more testing this evening...
Comment #20
Dasha_V - old commentedDuring the testing for the views 3.x it seems work fine initially.
But when theming 'search-result.tpl.php' - results stop showing because the available variables changed.
There is $view array instead of $url, $title, $info_split, etc.
This fix on the top of overwritten 'search-result.tpl.php' works for me
Do you know what can cause this issue?
Comment #21
NaX commentedUsing Views 2.12 and the latest patch from #19 I ran into some minor problems.
First I got include errors.
I solved this by copying the search modules search-result.tpl.php into the views/theme directory. I assume putting it into my theme would also solve this error.
But then I ran into the same problem that Dasha_V ran into. I put his workaround into the views/theme/search-result.tpl.php.
I also tried the search-results.tpl.php with the correct filename "views-view" prefix, that also did not work.
It looks like we need a preprocess function for something, to change the template file being used to the search modules template file and to extract the correct variables.
Comment #22
NaX commentedTo get the info variables working in the tpl file I also changed the render function to build the info variables.
Is there a reason we are doing this. If we are suppose to divide the score by the total, should the total not be relative the view instead of the entire node table. If this is correct should we not be using a static cache for this query.
Comment #23
damienmckennaHow about exposing it using the NODE_BUILD_SEARCH_RESULT node build mode?
Comment #24
damienmckennaFYI you can also implement my suggestion via hook_form_alter():
Comment #25
NaX commentedIf anybody is interested the attached patch is how I hacked D7 to get it to work. Its mostly based on the above. It should only work for nodes, but with the entity systems it should be possible to make it work for any entity.