vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   Search Bar in Static HTML Widget (https://vborg.vbsupport.ru/showthread.php?t=312994)

Several Zombies 07-15-2014 11:13 PM

Search Bar in Static HTML Widget
 
I'm trying to set a search bar up in the CMS using the static HTML widget, but no matter what I try, I get an error saying the security token is invalid or missing.

My code is as follows;

Quote:


<div style="white-space:nowrap">
<form action="search.php?search_type=1#ads=24" method="post">
<input type="hidden" name="do" value="process" />
<input type="hidden" name="s" value="$session[sessionhash]" />
<input type="hidden" name="securitytoken" value="$bbuserinfo[securitytoken]" />
<input type="hidden" name="showposts" value="0" />
<input type="hidden" name="quicksearch" value="1" />
<input type="text" style="width:150px;" class="bginput" name="query"/>
<input style="font: bold 10px Arial" type="submit" class="button" value="Search" /></form>
<a style="text-decoration:none" href="$vboptions[bburl]/search.php" accesskey="4" rel="nofollow" id="header_search" class=""></a><!--&nbsp;-->
</div>

Any ideas?

Dave 07-16-2014 07:22 AM

I think you're using vBulletin 3 syntax, you have to use {vb:raw session.sessionurl}, {vb:raw bbuserinfo.securitytoken}, search.php{vb:raw session.sessionurl_q} as variables. I'm not sure if that works in a widget though.

Lynne 07-16-2014 04:33 PM

If you are going to use variables, I think you need to use a PHP widget.

tbworld 07-16-2014 07:06 PM

As @Lynne was saying, you need a php widget.

Create a new widget template and insert the following:
Code:

<!-- 2014_07_16__php_search_widget -->
<style>
.tb_widget_content {
  background: #203020;
}
.tb_button {
  width: 24px;
  vertical-align: middle;
}
.tb_textbox {
  background: #A7B7A7;
  color: black;
  border: 0 none;
  height: 24px;
  width: 240px;
  font-size: 13px;
 }
.tb_advanced_search li a {
  color: white;
}
</style>

<div class="cms_widget">
<div class="block">
<div class="cms_widget_header widget_header">
    <h3><img src="{vb:stylevar imgdir_siteicons}/php.png" alt="" /> {vb:raw title}</h3>
</div>
<div class="cms_widget_content widget_content tb_widget_content">


    <form action="search.php?{vb:raw session.sessionurl}do=process" method="post" id="tb_search" class="tb_search">
        <input type="hidden" name="securitytoken" value="{vb:raw bbuserinfo.securitytoken}" />
        <input type="hidden" name="do" value="process" />
       
        <span>
            <input type="text"  class="tb_textbox textbox" value="" name="query" tabindex="99"/>
            <input type="image" class="tb_button" src="{vb:stylevar imgdir_button}/search.png" name="submit" onclick="document.getElementById('tb_search').submit;" tabindex="100"/>
        </span>
    </form>
   
    <!-- Advanced Search -->
    <ul class="tb_advanced_search">
        <li><a href="search.php{vb:raw session.sessionurl_q}" accesskey="4">{vb:rawphrase advanced_search}</a></li>
    </ul>


</div>
</div>
</div>

Notes
---------------
1.) This uses a php widget, but is not inserting any new php -- all variables that we are using are already registered in the normal vbulletin context. You should be trying this under the vbulletin default style.

2.) This is not inserted into the widget configuration. This code is added to a newly created template (Template Manager). Use the name of the template (case sensitive) and replace the template name in the widget configuration textbox (at the bottom of the widget configuration page).

:)


All times are GMT. The time now is 05:28 AM.

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.00926 seconds
  • Memory Usage 1,726KB
  • 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
  • (1)bbcode_code_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)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