Get Sugar CSS and JS in your files

sugarcrmdevelopers —  April 25, 2011

Editor’s Note: This post comes from the blog of Sugar Community member Milos Miric, who posts this great tip on pulling in all the CSS and Javascript includes from the current theme into your Smarty template.

 

Hey all, how many times have you made some php/html/smarty template files and been wondering how to get SugarCRM CSS and JS in it. Well here is the solution for you:

 

<?php

/**
* @author Milos Miric aka eitrix @ eontek.rs
*
*/

$themeObject = SugarThemeRegistry::current();
// get css
$css = $themeObject->getCSS();

// get JS
$js = $themeObject->getJS();

// assign smarty variables
$this->ss->assign("SUGAR_CSS",$css);
$this->ss->assign("SUGAR_JS",$js);

?>

Inside smarty template do:

{$SUGAR_CSS}
{$SUGAR_JS}

to get your css and js stuff printed out in page code

Share