View Full Version : Get CMS Section via Plugin
Yonatan
12-24-2010, 01:22 PM
Hello!
I had some issue at version 4.0.3 that I can't get the section ID.
It's been discussed already:
http://www.vbulletin.com/forum/showthread.php/348708-Get-CMS-section-in-plugin-code
https://vborg.vbsupport.ru/showpost.php?p=2017407&postcount=238
(and the next replies..)
and vBulletin developers also said that they will provide fix in 4.0.4+ version:
http://www.vbulletin.com/forum/showthread.php/348708-Get-CMS-section-in-plugin-code?p=1967245&viewfull=1#post1967245
But now I'm using in version 4.1.0 PL2 in the code:
global $sectionid;
$sectionid = $this->content->getParentId();
if ($sectionid == 3)
{
$vbulletin->options['selectednavtab']='content.php?r=3';
$tabselected = ' class="selected"';
$tablinks = '';
}
and it's not working!
Anyone have some solution to that issue?
Thanks!
Lynne
12-24-2010, 03:44 PM
What hook location? Also, why not just use $_GET['r']?
Yonatan
12-24-2010, 04:39 PM
What hook location? Also, why not just use $_GET['r']?
1) process_templates_complete.
2) Because those 2 issue's:
https://vborg.vbsupport.ru/showpost.php?p=2022201&postcount=249
https://vborg.vbsupport.ru/showpost.php?p=2025212&postcount=251
Lynne
12-24-2010, 05:27 PM
What are you expecting to happen from your plugin? All you've done is set some variables.... what are you going to do with them? That isn't going to make a navtab at all. So what is the expected result?
Getting the parentid works just fine if you use the hook location vbcms_content_populate_end. If you use vbcms_section_populate_end, then you will get the parentid of that section which is probably 1. But again, exactly what are you trying to do?
Yonatan
12-25-2010, 09:06 AM
What are you expecting to happen from your plugin? All you've done is set some variables.... what are you going to do with them? That isn't going to make a navtab at all. So what is the expected result?
Getting the parentid works just fine if you use the hook location vbcms_content_populate_end. If you use vbcms_section_populate_end, then you will get the parentid of that section which is probably 1. But again, exactly what are you trying to do?
I'm expecting from this plugin to behavior like any other default tabs - so if I'm on this tab, the Home tab will unselected and if I'm viewing in some article that related to this section id, this tab will highlighted.
Lynne
12-25-2010, 06:27 PM
You've done nothing in that plugin to insert a navtab into your navbar. You need to use a template_hook to insert it. Something like:
$template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href="link.php">Nav Link</a>'.$tablinks.'</li>' ;
You probably need to make $template_hook global also. And, you'll have to do something to the Home navtab plugin to not make it selected also since it is currently set to be the active tab is you are on a content page (you'll have to change the condition to be "on content page except these content pages....").
Yonatan
12-25-2010, 07:57 PM
You've done nothing in that plugin to insert a navtab into your navbar. You need to use a template_hook to insert it. Something like:
$template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href="link.php">Nav Link</a>'.$tablinks.'</li>' ;
You probably need to make $template_hook global also. And, you'll have to do something to the Home navtab plugin to not make it selected also since it is currently set to be the active tab is you are on a content page (you'll have to change the condition to be "on content page except these content pages....").
Of course I have more lines in that plug in(I just put the ones who related to this issue).
This is my whole code:
$tabselected = '';
$tablinks = '';
if (($_GET['r'] == 3) && (THIS_SCRIPT == 'vbcms'))
{
$vbulletin->options['selectednavtab']='content.php?r=3';
$tabselected = ' class="selected"';
$tablinks = '';
}
$template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href="content.php?r=3">Tab Name</a>'.$tablinks.'</li>' ;
And I didn't actually understood what you meant after that, can you explain me that again with some examples?
Thanks!
Lynne
12-25-2010, 08:53 PM
The variable, $template_hook, probably needs to be globalized (it did when I put the code into a plugin using the hook location vbcms_content_populate_end), or you will get no output.
Yonatan
05-30-2011, 09:44 PM
The variable, $template_hook, probably needs to be globalized (it did when I put the code into a plugin using the hook location vbcms_content_populate_end), or you will get no output.
Sorry for jumping this thread.
I've been searching for working code but I didn't find anything.
Can anyone give me some example for working code?
Thanks!
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.