Not logged in. · Lost password · Register
Forum: General Help and Support Development RSS
how to detect if current page is a sidebar?
Avatar
og #1
Member since May 2006 · 437 posts · Location: Bayern
Group memberships: Members
Show profile · Link to this post
Subject: how to detect if current page is a sidebar?
Some plugin functionality should behave different if used inside a sidebar (or rightsidebar or navbar). For example if the plugin uses current page context. If used inside a page, everything is straight forward, but if used in an sidebar it should not be relative to the sidebar-page but the shown page in main window.

My problem is, how to i know? Is it sufficient to check if current pagename is equal to $conf['sidebar']?
But this may handled seperately in the template configuration. For example i use bootstrap3 template, which supports both, a sidebar and a rightsidebar. The rightsidebar is not defined anywhere in configuration.
Oli...
Avatar
og #2
Member since May 2006 · 437 posts · Location: Bayern
Group memberships: Members
Show profile · Link to this post
After playing around a bit, i found that if i'm inside a sidebar, the $INFO['id'] differs from $ID. The former one seems to always contain the ID of the shown page in main, whereas the latter one holds the "currently processed" page. I gess sidebars are handlet by template, which renders them prior bevor content.

So IF this is correct, it could be decided by simply:
if ($ID != $INFO['id']) {
    // WOW, i found myself inside a sidebar
}
Oli...
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Go to forum
Imprint
This board is powered by the Unclassified NewsBoard software, 20150713-dev, © 2003-2015 by Yves Goergen
Current time: 2020-02-26, 15:30:30 (UTC +01:00)