vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Get CMS Section via Plugin (https://vborg.vbsupport.ru/showthread.php?t=255845)

Yonatan 12-24-2010 01:22 PM

Get CMS Section via Plugin
 
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/showt...in-plugin-code
https://vborg.vbsupport.ru/showpost....&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/showt...=1#post1967245

But now I'm using in version 4.1.0 PL2 in the code:
PHP 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

Quote:

Originally Posted by Lynne (Post 2138659)
What hook location? Also, why not just use $_GET['r']?

1) process_templates_complete.
2) Because those 2 issue's:

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

Quote:

Originally Posted by Lynne (Post 2138696)
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:

PHP Code:

$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

Quote:

Originally Posted by Lynne (Post 2138981)
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:

PHP Code:

$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:
PHP 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 08:44 PM

Quote:

Originally Posted by Lynne (Post 2139006)
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!


All times are GMT. The time now is 06:23 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.01940 seconds
  • Memory Usage 1,748KB
  • 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
  • (4)bbcode_php_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)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