The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
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! |
#2
|
|||
|
|||
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).
|
#3
|
|||
|
|||
Quote:
|
#4
|
|||
|
|||
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.
|
#5
|
|||
|
|||
kh99, you are correct. I am only interested in getting the keyword list.
|
#6
|
|||
|
|||
OK, you could create plugin using hook search_complete and this code:
PHP Code:
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> Code:
Keyword: test Keyword: OR moderators Anyway, I hope that helps. |
#7
|
|||
|
|||
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! |
#8
|
|||
|
|||
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. |
#9
|
|||
|
|||
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. |
#10
|
|||
|
|||
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? |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|