Back to vBulletin 5.x Template Modifications

[vBMods.rocks] Add Search Engine Search Result link on vB5 Search Result page
Mod Version: 1.00, by noypiscripter

vB Version: 5.5.5 Rating: (0 vote - 0 average) Installs: 1
Released: 01 Mar 2022 Last Update: Never Downloads: 0
Supported Template Edits  

In some cases, the vB5 search results may not provide you what you're searching for in a forum. You could https://vbmods.rocks/forum/vbulletin-5-modifications/vbulletin-5-products-and-extensions/9593-google-search-replacement or add a Google search result link (and other search engines) together with the vB5 search results. These search engine links will redirect the user to their search results for your site.

If you are more interested in the latter, then continue reading.

Before giving you the code to accomplish what is shown in the above screenshot, let me give you first the limitations/disadvantages of doing this modification:
  1. Your site must be public as search engines cannot index private pages.
  2. Your site will lose branding to search engines as users are taken out of your site and redirected to search engine search results page.
  3. Recent content from your forum may not be instantly available until search engines index your site.
  4. This mod requires editing the Search Results template which means the changes may cause template conflicts during upgrades.
  5. Since this requires template editing, this is not for vBCloud although there is another solution to implement it that will work on vBCloud.
If you are okay with the above, then proceed with these steps:
  1. Logon to AdminCP.
  2. Go to Styles → Search in Templates
  3. Choose the target style/theme in the "Search in Style" dropdown.
  4. In the "Search for Text" field, type widget_search_results.
  5. Select "Yes" in the "Search Titles Only" radio button.
  6. Click Find button.
  7. In the search results, double-click the template to edit it or select it then click Customize button.
  8. Find the following code (Click the Template input box and press Ctrl+F or Command+F)
    Code:
    <vb:if condition="!empty($nodes['ignored_keywords'])">
  9. Find its closing </vb:if> tag
  10. Below that code, insert the following code:
    Code:
    <vb:if condition="!empty($searchJSONStructure['keywords'])">
    	<p class="alternative-search-engine-search h-margin-top-l">
    	Can't find what you're looking for? See <a href="https://www.google.com/search?q={vb:urlencode {vb:raw searchJSONStructure.keywords}}+site%3A{vb:urlencode {vb:raw baseurl}}" target="_blank"><strong>Google</strong></a> search results for '{vb:raw searchJSONStructure.keywords}'.
    	</p>
    	</vb:if>
    That adds a Google search results link using the "site:" filter on search engines that search within the specified site URL which is your forum URL in this case. To add other search engine links, include the following hyperlink HTML:

    DuckDuckGo:
    HTML Code:
    <a href="https://duckduckgo.com/?q={vb:urlencode {vb:raw searchJSONStructure.keywords}}+site%3A{vb:urlencode {vb:raw baseurl}}" target="_blank"><strong>DuckDuckGo</strong></a>
    Bing:
    HTML Code:
    <a href="https://www.bing.com/search?q={vb:urlencode {vb:raw searchJSONStructure.keywords}}%20site%3A{vb:urlencode {vb:raw baseurl}}" target="_blank"><strong>Bing</strong></a>
    Yahoo:
    HTML Code:
    <a href="https://search.yahoo.com/search?p={vb:urlencode {vb:raw searchJSONStructure.keywords}}+site%3A{vb:urlencode {vb:raw baseurl}}" target="_blank"><strong>Yahoo</strong></a>
    Yandex:
    HTML Code:
    <a href="https://yandex.com/search/?text={vb:urlencode {vb:raw searchJSONStructure.keywords}}+site%3A{vb:urlencode {vb:raw baseurl}}" target="_blank"><strong>Yandex</strong></a>
    For example, on my forum, I added Google and DuckDuckGo. Here's the code I used:
    Code:
    <vb:if condition="!empty($searchJSONStructure['keywords'])">
    	<p class="alternative-search-engine-search h-margin-top-l">
    	Can't find what you're looking for? See <a href="https://www.google.com/search?q={vb:urlencode {vb:raw searchJSONStructure.keywords}}+site%3A{vb:urlencode {vb:raw baseurl}}" target="_blank"><strong>Google</strong></a> or <a href="https://duckduckgo.com/?q={vb:urlencode {vb:raw searchJSONStructure.keywords}}+site%3A{vb:urlencode {vb:raw baseurl}}" target="_blank"><strong>DuckDuckGo</strong></a> search results for '{vb:raw searchJSONStructure.keywords}'.
    	</p>
    	</vb:if>
  11. Click Save button.
  12. Repeat Steps 2-11 for other active styles/themes on your forum (if any).
Demo:
Try searching on my forum or clicking this search result:

https://vbmods.rocks/search?q=IP&searchJSON=%7B%22keywords%22%3A%22IP%22%7D

Enjoy!

Download

No files for download.

Screenshots

Click image for larger version
Name:	search-results.png
Views:	59
Size:	55.0 KB
ID:	158958  

Similar Mods

Show Thread Enhancements [vBMods.rocks] Add Custom Profile Fields in Postbit vBulletin 5.x Products & Extensions
Miscellaneous Hacks [vBMods.rocks] Add Detailed IP Info Modal to the Who's Online page vBulletin 5.x Template Modifications
Calendar Enhancements [vBMods.rocks] Event Date That Rocks using CSS vBulletin 5.x Template Modifications
Miscellaneous Hacks [vBMods.rocks] Quick fix for guests having no access to the reset-password page vBulletin 5.x Products & Extensions

vblts.ru supports vBulletin®, 2022-2024