Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 01-25-2012, 11:47 AM
BeoRski BeoRski is offline
 
Join Date: Apr 2008
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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!
Reply With Quote
  #2  
Old 01-25-2012, 12:37 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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).
Reply With Quote
  #3  
Old 01-25-2012, 02:26 PM
BeoRski BeoRski is offline
 
Join Date: Apr 2008
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
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. ^_^
Reply With Quote
  #4  
Old 01-25-2012, 02:39 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #5  
Old 01-25-2012, 02:43 PM
BeoRski BeoRski is offline
 
Join Date: Apr 2008
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

kh99, you are correct. I am only interested in getting the keyword list.
Reply With Quote
  #6  
Old 01-25-2012, 03:10 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
2 благодарности(ей) от:
BeoRski, Lynne
  #7  
Old 01-25-2012, 03:55 PM
BeoRski BeoRski is offline
 
Join Date: Apr 2008
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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!
Reply With Quote
  #8  
Old 03-21-2013, 04:57 AM
farru farru is offline
 
Join Date: Apr 2012
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #9  
Old 03-21-2013, 10:34 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #10  
Old 03-21-2013, 11:02 PM
tbworld tbworld is offline
 
Join Date: Oct 2008
Posts: 2,126
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:42 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.04051 seconds
  • Memory Usage 2,263KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_code
  • (1)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (2)post_thanks_box_bit
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete