vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Thread Prefix Variable to query (https://vborg.vbsupport.ru/showthread.php?t=323584)

siliconfinance 10-05-2016 09:28 PM

Thread Prefix Variable to query
 
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?

Dave 10-05-2016 09:35 PM

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
Code:

<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 [DATE]1475787179[/DATE] at [TIME]1475787179[/TIME] ---------------

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?

PHP 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?

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('prefix_choice_array_explode')) ? eval($hook) : false;



All times are GMT. The time now is 06:51 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.01261 seconds
  • Memory Usage 1,743KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete