Hi, I would like to know how I can use the $forumlist variable on other templates, so I can select the different categories, and integrate it with my coding.
This is what I mean:
Obviously I don't want to search for the topics, but it is an example taken from search.php. I need the $forumlist to contain all of the categories, so I can get the users to select a category, or multiple categories, and then click an input button.
I would need this to be displayed in the header template.
IIRC that. is generated with a ffunction.
make_searchable_forums() is the function that builds this select box for you. <UPDATED>
require_once MYBB_ROOT.'inc/functions_search.php';
/**
* Build a select box list of forums the current user has permission to search
*
* @param int The parent forum ID to start at
* @param int The selected forum ID
*
* @return string The forum select boxes
*/
$search_forum_list = make_searchable_forums(0, (isset($mybb->input['fid']) ? (int)$mybb->input['fid'] : 0));
$GLOBALS['forumlist'] = $GLOBALS['forumlistbits'] = '';
Then add {$search_forum_list} to your form template.
You will have access to the array of selected FIDs via $mybb->input['forums'] :
$forums = is_array($mybb->input['forums']) ? $mybb->input['forums'] : array();
var_dump($forums);
It works, but it conflicts with search.php. When I go on search.php, there are many $forumlists that appear and it's all messed up.
I used:
if (THIS_SCRIPT != 'search.php') {}
But then the code doesn't show up when I go to search.php but works well on every other page.
It seems as if the variables clash.
Try to use set $forumlistbits to an empty string right after you run the function. See my code above, I have updated it.
I added the code but it still conflicts with search.php, when I visit search.php. It breaks the entire page, with about 100 $forumlists on the page.
It makes the website page very long, with a lot to scroll down.
EDIT: The code below makes <navigation> to disappear. Why?
$pforumcache
EDIT: Nevermind. I just made a new global variable from $pforumcache, and now it works:
global $pforumcache;
$pforumcache_new = $pforumcache;
global $pforumcache_new;
Though the search.php page is still messed up.
Alright Greg, I updated my code above. It wasn't just the $forumlistbits but $forumlist as well.
I tested if it messed my search.php and it didn't.