Register Arama Bugünkü Mesajlar Tüm Forumu Okundu Say

Reply
 
Thread Tools
How-To Integrate Mod with forum search results
vB.Org Poster
vB.Org Poster has disabled reputation
Kayıt Tarihi: Jul 2018
Mesajlar: 298

Show Printable Version Email this Page
Makale: vBulletin 3 Makaleleri, yazan vB.Org Poster 10 Jul 2018, 18:37

Anyone who ever written a modification that was based on some custom access permissions (logic driven) should be aware about the "search" & "advanced search" pitfalls.

Let me explain the "problems" of these issues:
Say for example you wrote a mod that hide/deny certain thread/forum from user. Coder worked hard with mod coding, and made sure that user wouldnt see the link to that thread (either on forumhome, forumdisplay, thread listing, etc.). However, one need to remember the "search option & the fact that specific thread could be returned as part of search results shown to user.

The problem consisted of 2 pitfalls:
  1. Post listing in the search results.
  2. Forum listing in the advanced search.

Now that we recognize the problems, lets talk solutions

Solution to problem 1:
hook location: search_results_prebits
Code Approach Explained:
This hook will allow us to manipulate the results before sent to screen.
the search results are located into array var $itemids.
Common way to handle this, is by looping the array vars, and should we find any result line we wish to hide, we can simply unset it.
Code Example:
Lets assume we want to match for "forum id" & hide certain forum posts based on some logic behind it, thae hook plugin will look as follows:

Kod Blok Kilitli:      (Kayıt veya giriş yapmalısın)  
Engellenmiş, kayıtlı olmayan veya onay bekleyen kişiler kodlara erişemezler.


Solution to problem 2:
hook location: search_intro
Walkthrough: understanding what's going on in the background :
This hook will allow us to manipulate the data before showing the "advanced search" screen.
looking at the "search_forums" template, you will see this code secton:

Kod Blok Kilitli:      (Kayıt veya giriş yapmalısın)  
Engellenmiş, kayıtlı olmayan veya onay bekleyen kişiler kodlara erişemezler.

So we have a listbox (HTML select control), that it's items are placed by code into $searchforumbits. Taking a closer look into "search.php" will show you the following line:

Kod Blok Kilitli:      (Kayıt veya giriş yapmalısın)  
Engellenmiş, kayıtlı olmayan veya onay bekleyen kişiler kodlara erişemezler.

option is tempalte that looks like this:

Kod Blok Kilitli:      (Kayıt veya giriş yapmalısın)  
Engellenmiş, kayıtlı olmayan veya onay bekleyen kişiler kodlara erişemezler.

Code Approach Explained:
Hence, what we understand from all the above, inside the $forumbits var i'll find block of text, consisting of <option> lines, one for each of the forums we have.
Note since this is built inside the search.php (lines 2069-2100) we have no hook inside, allowing us to act during build of this list. Therefore our only option is to "retro" process this text block

Code Example:
My suggested code approach method is as follows:

Kod Blok Kilitli:      (Kayıt veya giriş yapmalısın)  
Engellenmiş, kayıtlı olmayan veya onay bekleyen kişiler kodlara erişemezler.

Code Explained:
  1. PHP function eregi() allows to perform regular expression match (the i means "case insensitive"). you can read about function eregi() here: PHP: eregi - Manual
  2. Regular expression written match for the number inside the value="x".
  3. The $dump holds the results. results is inside $dump[1] ($dump[0] holds the entire string matched);
  4. Once we've confirmed we want this line removed, we use php function str_replace() to replace forum option line with empty string. You can read about function str_replace here: PHP: str_replace - Manual


That's it

Hope this small guide helped anyone that wanted to do some modification integration into search option on forum & didnt know where to place code or how.
Views: 42
Reply With Quote
Reply

Thread Tools

Şunları Yapabilirsin
Yeni Konu Açmak
Konuya Cevap Yazmak
Eklenti Eklemek
Düzenleme Yapabilmek

Forum Atla


LD'de Yeni misin? Yardıma mı ihtiyacın var?

All times are GMT +3. The time now is 05:14.

Tasarım Özelliği | Genişlik: Geniş Renk: How-To Integrate Mod with forum search results How-To Integrate Mod with forum search results How-To Integrate Mod with forum search results How-To Integrate Mod with forum search results How-To Integrate Mod with forum search results