View Full Version : Getting the sub forum name from url
runnerjp
04-02-2012, 01:46 PM
If my url looks like this http://www.clubmonza.com/forums/forumdisplay.php?2-Main-Forum
How can i get the forum name from the url (Main-Forum)
Lynne
04-02-2012, 03:29 PM
Are you talking about getting it in a plugin or in a template? Can you be more specific about what you want. Or do you literally want to take "2-Main-Forum" and turn it into "Main-Forum"? If so, look at this PHP page on string functions - http://www.php.net/manual/en/ref.strings.php
runnerjp
04-02-2012, 03:44 PM
I just want to pull the current sub forum name the the url so i can use it in my external
so $_get["?????"]; will show my the sub forum
Where is the url coming from? I'm wondering if there could be any other parameters on the url. Also you're saying this is not a vb script, right?
runnerjp
04-04-2012, 08:17 AM
the url is coming from vbulletin. All i really need to do is if a user is in a sub forum i want to know who to find the sub form name using hard code.
Pandemikk
04-04-2012, 12:46 PM
$foruminfo['title'] contains the title of the forum a user is in. You'll need to use it in a hook, most likely forumdisplay_start.
There's no reason to try and grab it from the URL, that's just over-complicating it.
runnerjp
04-04-2012, 03:24 PM
What do you mean by a hook??
My code looks like this
<?php
session_start();
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
// #################### DEFINE IMPORTANT CONSTANTS #######################
define('THIS_SCRIPT', 'index');
define('CSRF_PROTECTION', true);
define('CSRF_SKIP_LIST', '');
define('VB_ENTRY', 'forum.php');
// get special data templates from the datastore
$specialtemplates = array(
'userstats',
'birthdaycache',
'maxloggedin',
'iconcache',
'eventcache',
'mailqueue',
'activeblocks',
);
// pre-cache templates used by all actions
$globaltemplates = array(
'ad_board_after_forums',
'ad_board_below_whats_going_on',
'block_blogentries',
'block_cmsarticles',
'block_newposts',
'block_sgdiscussions',
'block_tagcloud',
'block_threads',
'block_html',
'FORUMHOME',
'forumhome_event',
'forumhome_subforums',
'forumhome_forumbit_level1_nopost',
'forumhome_forumbit_level1_post',
'forumhome_forumbit_level2_nopost',
'forumhome_forumbit_level2_post',
'forumhome_lastpostby',
'tag_cloud_link',
);
// pre-cache templates used by specific actions
$actiontemplates = array();
// ######################### REQUIRE BACK-END ############################
require_once('./global.php');
require_once(DIR . '/includes/functions_bigthree.php');
require_once(DIR . '/includes/functions_forumlist.php');
echo "...".$foruminfo['title'] ;
?>
<img src="http://www.clubscuderia.co.uk/forum/sponsors/forums/autoficcinaforum.jpg" />
Pandemikk
04-04-2012, 03:30 PM
I mean. You're going about this all wrong...
Go to products and plugins -> create new plugin -> hook location: forumdisplay_start
runnerjp
04-04-2012, 03:45 PM
in my adds i use this to get the add
<center><iframe width="800" frameborder="0" height="110" src="http://www.clubmonza.com/forums/theadds.php"></iframe></center>
now i have made the plugin how to i call it within the Ad HTML section in advertising banners
You could try this: create a new plugin using hook location parse_templates and this code:
global $foruminfo;
vB_Template::preRegister('ad_global_above_footer', array('foruminfo' => $foruminfo));
Then in your ad html, put {vb:raw foruminfo.title} where you want to use it.
ETA:...you also need to change the template name (in red) to the template for the ad location you're using - ad_global_above_footer was just an example.
runnerjp
04-05-2012, 08:57 AM
I cant find parse_templates in hooks :S
Lynne
04-05-2012, 04:04 PM
I cant find parse_templates in hooks :S
It's definitely there in my 4.1.11 install.
If you're not familiar with creating a plugin, you can search for "Adding or Editing a Plugin" in the vbulletin manual: https://www.vbulletin.com/docs/html?manualversion=40111601 . In case there's any confusion, I was talking about the "Hook Location" drop-down menu when you're creating a plugin.
Also, I edited my post above - I forgot to mention above that 'ad_location_above_footer' was just an example template name.
runnerjp
04-06-2012, 08:11 AM
Ok i have got the forum name :) issue is i have written my code in php and dont nknow how to get it to work within a template.
foruminfo.title could really be the id so foruminfo.threadid but that does not seem to work
include_once "../shared/ez_sql_core.php";
include_once "ez_sql_mysql.php";
$db = new ezSQL_mysql('db_user','db_password','db_name','db_ host');
$results = $db->get_results("SELECT name, email FROM users");
foreach ( $results as $user ) {
If ($user->name == {vb:raw foruminfo.title})
{
?>
<iframe width="800" frameborder="0" height="110" src="http://www.clubmonza.com/forums/<?php echo {vb:raw foruminfo.title} ?> "></iframe>
<?
}
}
?>
The way the code works is if in the database someone has selected to show a special banner on a forum page then it shows. Issue is i have no idea where to add it within the plugins or templates
Pandemikk
04-06-2012, 10:07 AM
...What are you doing?
Why are you trying to connect to ezSQL_mysql? Get rid of that junk and use the normal database abstraction layer!
Secondly, you're comparing a username to a forum's title and you wonder why you're not getting results?
Thirdly, you're using template syntax within a PHP file?!
runnerjp
04-06-2012, 09:03 PM
the username was incorrect it was just an example.
Thirdly, you're using template syntax within a PHP file?! < this is what i dont understand how do i split the two up?
Pandemikk
04-07-2012, 12:06 AM
the username was incorrect it was just an example.
Thirdly, you're using template syntax within a PHP file?! < this is what i dont understand how do i split the two up?
You have to use template syntax within a template. ;)
There's plenty of articles on this here: https://vborg.vbsupport.ru/forumdisplay.php?f=242
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.