Kunena 6.2.6 released

The Kunena team has announce the arrival of Kunena 6.2.6 [K 6.2.6] which is now available for download as a native Joomla extension for J! 4.4.x/5.0.x. This version addresses most of the issues that were discovered in K 6.1 / K 6.2 and issues discovered during the last development stages of K 6.2

This category contains miscellaneous, uncategorised user contributions, (templates, modules, plugins and hacks) relating to older versions of Kunena that are no longer supported.

The topics in this category are for historical interest only. Owing to the structural changes that occurred in K 2.0, many of the ideas in these topics will not work with later versions and, for that reason, the topics are locked.

Question Workaround for the Blue Eagle initialize.php IE7 css loading in body

More
11 years 8 months ago - 11 years 8 months ago #1 by Mike-XS
Hi.. In the Blue Eagle template of Kunena 2.0.1, I noticed that in the initialize.php file, the conditional css check for IE7 browsers and below loads the css file into the body of the page instead of in the head.

Code:
<!--[if lte IE 7]> <link rel="stylesheet" href="<?php echo $cssurl; ?>/kunena.forum.ie7.css" type="text/css" /> <![endif]-->

You can check the kunena forum index page here on this site to see the example :

Code:
<div class="component-pad"> <!--[if lte IE 7]> <link rel="stylesheet" href="/components/com_kunena/template/blue_eagle/css/kunena.forum.ie7.css" type="text/css" /> <![endif]--> <div id="Kunena" class="layout">


Sure it's not the end of the world, but I didn't want it that way in my template. ;)

As a quick workaround I changed it to this in my own template (initialize.php) to load the css file in the head if IE 5-7 is detected..

Code:
// Load Conditional IE CSS in head if(!empty($_SERVER['HTTP_USER_AGENT'])) { $ua = (string) trim(strip_tags($_SERVER['HTTP_USER_AGENT'])); if(preg_match('#MSIE (5|6|7)#i',$ua)){ CKunenaTools::addStyleSheet( JURI::root(true) . '/components/com_kunena/template/dark_eagle/css/kunena.forum.ie7.css'); } unset($ua); }

If you have a better way of doing it, please post your code here B)
Last edit: 11 years 8 months ago by Mike-XS.

Please Log in or Create an account to join the conversation.

More
11 years 8 months ago - 11 years 8 months ago #2 by Mike-XS
Ok, well there's a few different ways of adding css.

This is a much better way to add the IE7 conditional css than how it's done in the Blue Eagle template at the moment. It's also available in another Kunena function, which could have been be used too.

The Joomla way
Code:
$stylelink = '<!--[if lte IE 7]>' ."\n"; $stylelink .= '<link rel="stylesheet" href="css/kunena.forum.ie7.css" type="text/css" />' ."\n"; $stylelink .= '<![endif]-->' ."\n"; $document->addCustomTag($stylelink);

More:
docs.joomla.org/Adding_Javascript_and_CSS_to_the_page

--

A few notes for adding stylesheets.

Using $template->addStyleSheet minimizes the CSS files.
Code:
if (file_exists ( JPATH_ROOT . "/templates/{$app->getTemplate()}/css/kunena.forum.css" )) { // Load css from Joomla template CKunenaTools::addStyleSheet ( JURI::root(true). "templates/{$app->getTemplate()}/css/kunena.forum.css" ); if ($skinner && file_exists ( JPATH_ROOT. "templates/{$app->getTemplate()}/css/kunena.skinner.css" )){ CKunenaTools::addStyleSheet ( JURI::root(true). "templates/{$app->getTemplate()}/css/kunena.skinner.css" ); } elseif (!$skinner && file_exists ( JPATH_ROOT. "templates/{$app->getTemplate()}/css/kunena.default.css" )) { CKunenaTools::addStyleSheet ( JURI::root(true). "templates/{$app->getTemplate()}/css/kunena.default.css" ); } } else { // Load css from default template $template->addStyleSheet ( 'css/kunena.forum.css' ); if ($skinner) { $template->addStyleSheet ( 'css/kunena.skinner.css' ); } else { $template->addStyleSheet ( 'css/kunena.default.css' ); } }

--

If you don't want autogenerated minimised css files, use $document->addStyleSheet instead.

Note that you will need to provide the path to the CSS file
Code:
if (file_exists ( JPATH_ROOT . "/templates/{$app->getTemplate()}/css/kunena.forum.css" )) { // Load css from Joomla template $document->addStyleSheet ( JURI::root(true). "templates/{$app->getTemplate()}/css/kunena.forum.css" ); if ($skinner && file_exists ( JPATH_ROOT. "templates/{$app->getTemplate()}/css/kunena.skinner.css" )){ $document->addStyleSheet ( JURI::root(true). "templates/{$app->getTemplate()}/css/kunena.skinner.css" ); } elseif (!$skinner && file_exists ( JPATH_ROOT. "templates/{$app->getTemplate()}/css/kunena.default.css" )) { $document->addStyleSheet ( JURI::root(true). "templates/{$app->getTemplate()}/css/kunena.default.css" ); } } else { // Load css from default template $document->addStyleSheet ( JURI::root(true) . "/components/com_kunena/template/{$template->name}/css/kunena.forum.css" ); if ($skinner) { $document->addStyleSheet ( JURI::root(true) . "/components/com_kunena/template/{$template->name}/css/kunena.skinner.css" ); } else { $document->addStyleSheet ( JURI::root(true) . "/components/com_kunena/template/{$template->name}/css/kunena.default.css" ); } }

--

Another way is by using the addIEStylesheet method from the Kunena Template class, which implements the Joomla addCustomTag method.

I tested with this in my own template.php and added a couple of extra params for the css file path into the getFile method which weren't available for me to use in the base class.
Code:
// extend KunenaTemplate public function addIEStyleSheet($filename, $condition='IE') { $url = $this->getFile($filename, true , '', 'components/com_kunena'); $stylelink = "<!--[if {$condition}]>".PHP_EOL; $stylelink .= '<link rel="stylesheet" href="'.$url.'" />' . PHP_EOL; $stylelink .= "<![endif]-->".PHP_EOL; JFactory::getDocument()->addCustomTag($stylelink); }

And used like this in the intialize.php:
Code:
$filename = 'template/dark_eagle/css/kunena.forum.ie7.css'; $this->addIEStyleSheet($filename, 'lte IE 7');

--
Last edit: 11 years 8 months ago by Mike-XS.

Please Log in or Create an account to join the conversation.

More
11 years 8 months ago #3 by TKtemp
Hi Mike,

what is IE7?????

Something good to eat ???

Please Log in or Create an account to join the conversation.

More
11 years 8 months ago - 11 years 8 months ago #4 by Mike-XS
IE is something that should probably be tied to an anchor and thrown overboard in the ocean. :P

Or fed to godzilla.. :ohmy:

Or shot out into deep space, never allowed to return.. :unsure:

Or shipped off to a hammer testing facility in siberia.. :woohoo:
Last edit: 11 years 8 months ago by Mike-XS.

Please Log in or Create an account to join the conversation.

Time to create page: 0.350 seconds