1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

admin vs public css

Discussion in 'XenForo Development Discussions' started by Jake Bunce, Aug 11, 2013.

  1. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    I currently do this in 1.2 to know if I'm in admin versus public:

    			$isAdmin = (   XenForo_Application::getFc()->getDependencies()->getBaseViewClassName() == 'XenForo_ViewAdmin_Base'   );
    			$isPublic = (   XenForo_Application::getFc()->getDependencies()->getBaseViewClassName() == 'XenForo_ViewPublic_Base'   );
    			if ($isPublic)
    				$template->addRequiredExternal('css', 'nat_public_css');
    			else if ($isAdmin)
    				$template->addRequiredExternal('css', 'nat_admin_css');
    What other methods do people use?

    Some older addons are encountering conflicts with NodesAsTabs because it uses XenForo_Application::getFc() which is new to 1.2. So I want to use a different method to avoid causing errors in other addons.
  2. Jeremy

    Jeremy Well-Known Member

    Jake Bunce likes this.
  3. Chris D

    Chris D XenForo Developer Staff Member

                if ($template instanceof XenForo_Template_Public)
    $isPublic true;
    $isAdmin false;
    Should do it :)
    Jake Bunce likes this.
  4. Robbo

    Robbo Well-Known Member

    Just use http://au1.php.net/class_exists with autoload set to false on XenForo_Dependencies_Admin if you want to do it anywhere. Otherwise instanceof if you have a class to reference in those cases.
    Jake Bunce likes this.
  5. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Used the code Chris posted. It works.
    Chris D likes this.

Share This Page