View Full Version : Thread Prefix Variable to query
siliconfinance
10-05-2016, 09:28 PM
I want to display a certain banner when someone searches for threads with a given prefix.
I have tried a ton of variables and really have no idea and none of my searches have revealed anything.
Does anybody know what prefix variable to query in a conditional statement that will show as TRUE when someone searches with a given prefix?
Can you paste some of the queries you have tried?
My guess is that you need a simple LIKE such as WHERE variable LIKE 'somestring%'
That will show all variables that start with somestring.
Or are you talking about actual thread prefixes that you can define in the AdminCP?
Lynne
10-06-2016, 12:27 AM
In addition to what Dave asked, please post the hook location you are using for the query or the code script/area you are adding it. You may be using a variable that isn't available in the hook/script you are putting it in.
siliconfinance
10-06-2016, 01:47 AM
Essentially, I would like to trigger this banner when a specific search where all threads with the same prefix are displayed.
I am planning to put the conditional in: ad_navbar_below
and trigger it on the search script pages (as mentioned):
Ultimately I plan to join these two conditionals. The first is working
<if condition="THIS_SCRIPT == 'search'"></if>
None of these have worked; my prefix ID is exterior. I have tried:
<if condition="$prefixid == exterior">banner code</if>
<if condition="$prefixid == 'exterior'">banner code</if>
<if condition="$prefixchoice == 'exterior'">banner code</if>
<if condition="$prefixchoice[exterior]">banner code</if>
<if condition="$prefixchoice['exterior']">banner code</if>
<if condition="$prefixchoice == 'exterior'">banner code</if>
<if condition="$prefixchoice == exterior">banner code</if>
<if condition="$prefix_selected['exterior']">banner code</if>
<if condition="$prefix_selected[exterior]">banner code</if>
<if condition="$prefix_selected == exterior">banner code</if>
<if condition="$prefix_selected == 'exterior'">banner code</if>
--------------- Added 1475787179 at 1475787179 ---------------
Bump
Lynne
10-06-2016, 07:19 PM
The search page allows you to select multiple prefixes. So, you are going to need to put code in a hook to take the prefixchoice array and explode it before you can actually use it in a condition.
siliconfinance
10-06-2016, 08:19 PM
Wow Lynne, thank you!
Can you provide any guidance on how I might be able to accomplish that?
Go easy on this amateur!
Lynne
10-06-2016, 11:36 PM
If you look at the search.php file and do a search on "prefixchoice", you will see them take the variable and then explode it to get something that is useful.
siliconfinance
10-07-2016, 09:06 PM
Are you talking about this code?
if ($prefixchoice)
{
$prefix_sql = array();
foreach (explode(',', $prefixchoice) AS $prefixid)
{
if ($prefixid == '-1')
{
// no prefix
$prefix_sql[] = "''";
}
else
{
$prefix_sql[] = "'" . $db->escape_string($prefixid) . "'";
}
}
$thread_query_logic[] = "thread.prefixid IN (" . implode(',', $prefix_sql) . ")";
}
($hook = vBulletinHook::fetch_hook('search_process_fetch')) ? eval($hook) : false;
Lynne
10-08-2016, 02:48 PM
Well, that is an example of exploding it into an array, yes.
siliconfinance
10-18-2016, 03:54 PM
Thank you for your input and response.
If I understand correctly, would creating the following in a hook named 'prefix_choice_array_explode' work for my purposes?
if ($prefixchoice)
{
$prefix_sql = array();
foreach (explode(',', $prefixchoice) AS $prefixid)
{
if ($prefixid == '-1')
{
// no prefix
$prefix_sql[] = "''";
}
else
{
$prefix_sql[] = "'" . $db->escape_string($prefixid) . "'";
}
}
$thread_query_logic[] = "thread.prefixid IN (" . implode(',', $prefix_sql) . ")";
}
($hook = vBulletinHook::fetch_hook('prefix_choice_array_exp lode')) ? eval($hook) : false;
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.