vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Help: Strip formatting from {vb:raw criteriaDisplay} (https://vborg.vbsupport.ru/showthread.php?t=277531)

BeoRski 01-25-2012 11:47 AM

Help: Strip formatting from {vb:raw criteriaDisplay}
 
It would be great if {vb:raw criteriaDisplay} only returns the raw keywords without the html formatting tags and the prefix "Keyword(s): ". This will greatly help everyone in customizing their forums or in my case, implement Google's Limited Release Adsense for Search feature.

Example: If you search for vBulletin Suite the above variable will return "Keyword(s): <b><u>vBulletin</u></b>, <b><u>Suite</u></b>". It would be better if it simply returned "vBulletin, Suite" as the formatting and the prefix can easily be added through the template.

Any suggestions on how to go around this will be highly appreciated. Thanks!

kh99 01-25-2012 12:37 PM

The prefix is the phrase key_words, so you could possibly edit that (although for some reason it doesn't include the ':' or the parameters). The separating tags are hard-coded in vb/search/criteria.php. You could possibly create a plugin using hook search_complete and make some changes to the criteria string (note that the keywords is only one of the possible criteria displayed in that string).

BeoRski 01-25-2012 02:26 PM

Quote:

Originally Posted by kh99 (Post 2292195)
The prefix is the phrase key_words, so you could possibly edit that (although for some reason it doesn't include the ':' or the parameters). The separating tags are hard-coded in vb/search/criteria.php. You could possibly create a plugin using hook search_complete and make some changes to the criteria string (note that the keywords is only one of the possible criteria displayed in that string).

Thank you for your response. If we change it through a plugin, I assume it will also change the overall behavior of the variable. How can we change it so that it is passed on as another variable? I am not a developer but I understand some of the concepts. I would appreciate examples if possible. ^_^

kh99 01-25-2012 02:39 PM

Well, I'm confused about exactly what you want to do. Like I mentioned above, the keywords are only one criteria that can be displayed in the {vb:raw criteriaDisplay} variable, so it seems like you'd want to separate them all, which is a bit more work. Unless you have a separate use for just a list of the keywords? In any case I agree that they have made it very difficult to customize that part of the results display. Most of vb separates the display formatting from the logic, but the search criteria class mostly does it's own formatting for some reason.

BeoRski 01-25-2012 02:43 PM

kh99, you are correct. I am only interested in getting the keyword list.

kh99 01-25-2012 03:10 PM

OK, you could create plugin using hook search_complete and this code:

PHP Code:

if (get_class($this) == 'vb_Search_Resultsview')
{
   
$this->template->register('keywords'$criteria->get_keywords());



Then in the template, keywords is an array of arrays, like is described in this comment from the get_words function:

Code:

        *        Return the parsed keywords to filter
        *
        *        @return array.  An array of array("word" => $word, "joiner" => $joiner)
        *        where $word is the keyword and $joiner indicates how the word should be
        *                joined to the query.  $joiner should be one of "AND", "OR", or "NOT"
        *                with the exception of the first item for which $joiner is NULL.
        *                It is up to the search implementation to define exactly how to treat
        *                the words specified.
        */
        public function get_keywords()


So for instance I could put this in the template:

Code:

<vb:each from="keywords" value="keyword">
Keyword: {vb:raw keyword.joiner} {vb:raw keyword.word}<BR />
</vb:each>

Then when I search for test OR moderators (for example), I get this output:

Code:

Keyword: test
Keyword: OR moderators


Anyway, I hope that helps.

BeoRski 01-25-2012 03:55 PM

Wow! Thank you very much. I will try it out and post a feedback. ^_^

--------------- Added [DATE]1327511155[/DATE] at [TIME]1327511155[/TIME] ---------------

I have successfully implemented this. Thank you so much for your help kh99!

farru 03-21-2013 04:57 AM

Hey there,

Sorry for bringing this thread back from the dark. I am running 4.2.0 and can't seem to find any reference of 'search_complete' in templates. I assume the template name has been changed? Or, may be i am not looking in the right spot. If anyone can point me in the right direction, i would really appreciate that.

kh99 03-21-2013 10:34 AM

search_complete is a hook location for plugins. If you want to implement the above, you need to go to Plugins & Products > Add New Plugin and select search_complete from the Hook Location dropdown. You also need a title (something so that you'll remember what it's for years from now). Then copy the code into the large box, select the 'Yes" radio button to make it active, and Save.

Then you'd also need to edit the search_resultlist template as is mentioned above.

tbworld 03-21-2013 11:02 PM

KH99 - I am a big fan. Thanks so much for taking the time to help so many people here. I constantly find your replies insightful :).

In my journeys, I noticed that plugin 'search_complete' appears in 'resultsview.php' and 'search.php'. I see why this might be needed, but it also seems as it could cause problems if the user doesn't know. Am I missing something in this assumption?


All times are GMT. The time now is 09:56 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01009 seconds
  • Memory Usage 1,740KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code_printable
  • (1)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete