vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Include Search on Another Page (https://vborg.vbsupport.ru/showthread.php?t=182090)

zivester 06-10-2008 02:28 PM

Include Search on Another Page
 
Is there a way for me to include my forum search in another page? I've looked through the code and there are hidden attributes that have random ID's, so it makes me kind of weary.

Is it possible to add forum search, as well as Member search to another page of my website? If so have you done it and how can it be done?

Lynne 06-10-2008 02:52 PM

I think if you just include globals.php you will be able to include it. I have search included on a page I wrote and it works fine (you do need to make sure to include all the hidden inputs in the form).

zivester 06-10-2008 03:37 PM

I included global.php, and hidden input elements of the form... I get the following error on search:

Code:

Your submission could not be processed because a security token was missing or mismatched.
Actually, if I include global.php from the forums, my page doesn't load... (btw I'm modding a photopost page to include the forum search).


[EDIT] Oh, I don't know if this matters... but I'm manually copying the fields from the search page to my other page to be able to format it the way I want.

Lynne 06-10-2008 05:01 PM

You should copy the code for the form from the default vbulletin template because it will include the security token in it.

Did you use the 'template' in the article for How to create your own vBulletin-powered page! (uses vB templates) to start your new page? You might want to read that article. I think you need to include a new line about the security token in the php page. Take a look in that article and see if it's mentioned.

edit: This article tells you what to put at the top of your page to deal with the security token - Implementing CSRF Protection in modifications

zivester 06-10-2008 06:27 PM

Thanks for the links Lynne... but my php is dieing...

Here is the top of my php file, it crashes on the require:

Code:


error_reporting(E_ALL & ~E_NOTICE);

define('NO_REGISTER_GLOBALS', 1);

define( 'THIS_SCRIPT', "search" );
define('CSRF_PROTECTION', true);

//require_once( "{$Globals['PP_PATH']}/forum/global.php" );


Lynne 06-10-2008 07:19 PM

Quote:

Originally Posted by zivester (Post 1546039)
Thanks for the links Lynne... but my php is dieing...

Here is the top of my php file, it crashes on the require:

Code:


error_reporting(E_ALL & ~E_NOTICE);

define('NO_REGISTER_GLOBALS', 1);

define( 'THIS_SCRIPT', "search" );
define('CSRF_PROTECTION', true);

//require_once( "{$Globals['PP_PATH']}/forum/global.php" );


Have you tried changing the require_once to include the actual path and see if that works? Is this page you are adding in the forum directory? If so, just include it like this:
Code:

require_once('./global.php');
If it's in a different directory, then do a chdir first, like this:
Code:

chdir('/path/to/forum/');
require('./global.php');


zivester 06-10-2008 07:29 PM

Ya I learned that issue.. so I'm past that part... right now I'm getting the search to show up, but the values for half of the options are blank!?

Code:

chdir('/my/dir/mysite/forum/');
require('./global.php');

// #######################################################################                                                                                                                                                                 
// ######################## START MAIN SCRIPT ############################                                                                                                                                                                 
// #######################################################################                                                                                                                                                                 
                                                                                                                                                                                                                                           
$navbits = array();
$navbits[$parent] = 'Test Page';

$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');                                                                                                                                                                 
eval('print_output("' . fetch_template('search_forums') . '");');


EDIT: in IE, there are numerous Javascript errors when I include it as stated above... I think these are causing the problem. Another note, I'm not running this from within the vBulletin portion of my server, but one directory down.

--------------- Added [DATE]1213132230[/DATE] at [TIME]1213132230[/TIME] ---------------

EDIT EDIT:

memberlist_search template included doesn't work either... I must be missing an include or the javascript is screwing it up?

--------------- Added [DATE]1213156743[/DATE] at [TIME]1213156743[/TIME] ---------------

Here's a link to the test page to see what I mean:

Code:

http://www.streetstyle.com/search2.php

Any help appreciated :(

Dismounted 06-11-2008 07:12 AM

Put this at the top of your headinclude template.
HTML Code:

<base href="http://www.streetstyle.com/forum/" />

zivester 06-11-2008 01:03 PM

That didn't change anything... :-/

I've linked it back to the search_forums template, in order to work out the kinks... Here is the whole file for search2.php:

Code:

<?php

  // ####################### SET PHP ENVIRONMENT ###########################                                                                                                                                                               
error_reporting(E_ALL & ~E_NOTICE);                                                                                                                                                                                                         

  // #################### DEFINE IMPORTANT CONSTANTS #######################                                                                                                                                                               
define('NO_REGISTER_GLOBALS', 1);                                                                                                                                                                                                           
define('THIS_SCRIPT', 'search2'); // change this depending on your filename                                                                                                                                                                   

// ################### PRE-CACHE TEMPLATES AND DATA ######################                                                                                                                                                                 
// get special phrase groups                                                                                                                                                                                                               
$phrasegroups = array(

);

// get special data templates from the datastore                                                                                                                                                                                           
$specialtemplates = array(

);

// pre-cache templates used by all actions                                                                                                                                                                                                 
$globaltemplates = array(
                        'SEARCH2',
                        );

// pre-cache templates used by specific actions                                                                                                                                                                                             
$actiontemplates = array(

);

// ######################### REQUIRE BACK-END ############################                                                                                                                                                                                                                                                                                                                                                         
chdir('/my/stuffhtml/blah/forum/');
require('./global.php');

// #######################################################################                                                                                                                                                                 
// ######################## START MAIN SCRIPT ############################                                                                                                                                                                 
// #######################################################################                                                                                                                                                                 
                                                                                                                                                                                                                                           
$navbits = array();
$navbits[$parent] = 'Test Page';

$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') .'";');                                                                                                                                                                         
eval('print_output("' . fetch_template('search_forums') . '");');
                                                                                                                                                   
?>


Lynne 06-11-2008 01:58 PM

So, with the script you just posted, what sort of errors or results are you getting?


All times are GMT. The time now is 07:55 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.01119 seconds
  • Memory Usage 1,806KB
  • 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
  • (8)bbcode_code_printable
  • (1)bbcode_html_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete