检查Joomla View类

We are building a base theme to the future, and we are about to set a method to load a specific stylesheet if the joomla site has some component.

We have this code:

defined('_JEXEC') or die;
$doc        = JFactory::getDocument();
$config = JFactory::getConfig();
$params     = $this->getParams();
$uri = JFactory::getURI();
$ID_url = $uri->toString();
$view = $this->getView( 'components', 'html' );

And to check the class this:

 if ($view == 'com_component1'){
    $this->addStyleSheet('//cloud.typography.com/7794632/4177/css/style.css');
    }

Any idea of our error ?

Our idea is the $view is equal to com_component1 then load the stylesheet.

Thanks for the help.

Solution

defined('_JEXEC') or die;
$doc        = JFactory::getDocument();
$config = JFactory::getConfig();
$params     = $this->getParams();
$uri = JFactory::getURI();
$ID_url = $uri->toString();
$view = JFactory::getApplication()->input->get('option');

And them

 if ($view == 'com_easyblog'){
$this->addStyleSheet('//cloud.typography.com/7794632/4177/css/fonts.css');
}