vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   vBCMS - Detect articles in section X (https://vborg.vbsupport.ru/showthread.php?t=281010)

LOGECT 04-02-2012 12:41 PM

vBCMS - Detect articles in section X
 
Hello

I would like to use some different style/lang for my articles in section for example X than Y, so i need to separate them, the only way i find was the following code and the problem is that i have to writ the $_GET['r'] == x manually for every each article.
I believe that there should be a way to detect all articles in section X instant of writing the numbers manually.

Any help would be great.
Thank you

Code:

if (( $_GET['r'] == x OR $_GET['r'] == xx OR $_GET['r'] == xx) && (THIS_SCRIPT == 'vbcms')) 
{
    Do somthing

}
else
{
    Do somthing

}


Dead Eddie 04-03-2012 10:54 AM

PHP Code:

$this->content->getSectionId();
$this->content->getParentId();
(array) 
$this->content->getParentIds(); 

Depending on your requirement, one of these, called from any of the vbcms_article_populate_* hooks, should get you what you're looking for.

LOGECT 04-03-2012 08:42 PM

Quote:

Originally Posted by Dead Eddie (Post 2316315)
PHP Code:

$this->content->getSectionId();
$this->content->getParentId();
(array) 
$this->content->getParentIds(); 

Depending on your requirement, one of these, called from any of the vbcms_article_populate_* hooks, should get you what you're looking for.

Thanks for your reply, it doesn't work for me, i'v also followed this thread at vb.com:
https://www.vbulletin.com/forum/show...in-plugin-code

Dead Eddie 04-03-2012 08:47 PM

What specifically doesn't work? Can you post some sample code, along with which hook you're putting it in, what you expect to see, and what you're seeing?

LOGECT 04-03-2012 08:55 PM

I have created a plugin with hook location vbcms_article_populate_end and this code:

Code:

global $sectionid;
$sectionid = $this->content->getParentId();

Then I have a plugin with hook location init_startup:

Code:

if ($sectionid == x) 
{
        ...

}
else
{
        ...

}

I've also tried this with 2 plugins.

Dead Eddie 04-04-2012 01:47 PM

Whoops! That's not going to work! init_startup is called a little to early. I'd wager $sectionid isn't available either.

I have an idea on how to do this...I'll take another quick look tonight.


All times are GMT. The time now is 09:13 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.00960 seconds
  • Memory Usage 1,725KB
  • 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
  • (3)bbcode_code_printable
  • (2)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)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