<?php if($_COOKIE['lang'] != 'en') echo '<link rel="stylesheet" href="css/'.$_COOKIE['lang'].'.css"/>'; ?>
With this above script you get the stylesheet for the language that is selected.
Like if you select France you get the stylesheet fr.css
But now I want the same for IE so I thought something like this.
<?php if($_COOKIE['lang'] != 'en') echo '<link rel="stylesheet" href="css/'.$_COOKIE['lang'].'ie.css"/>'; ?>
So now when you click on France it also opens frie.css
But what do I write in here to make it only for IE
<!--[if IE]><style>#import url('/css/ie.css');</style><![endif]-->
Thanks!
<?php
if($_COOKIE['lang'] != 'en'){
printf('<!--[if IE]><style>#import url(\'/css/%sie.css\');</style><![endif]-->', $_COOKIE['lang']);
}
?>
This is what you need to write. You can also check in PHP headers if browser is Internet Explorer.
You can use $_SERVER['HTTP_USER_AGENT'] or get_browser() function to check it in PHP.
You can use this :
<!--[if IE]>
<link rel="stylesheet" type="text/css" href="all-ie-only.css" />
<![endif]-->
You can refer to below line :
https://css-tricks.com/how-to-create-an-ie-only-stylesheet/
Related
i am using transposh to translate my website from English to Arabic but when i switch language to Arabic it switches the style.css and it reverse the layout of my website leading to a mess, so i made a new style.css which works with the Arabic version very well but now i don't know how to link them together i mean i want to know how to make it switch the css file when it switches the language.
i tried this code but it didn't work
<?php if(MY_CUR_LANG == 'en'){?>
<link rel="stylesheet" href="http://localhost/wordpress/wp-content/themes/style.css" type="text/css" media="screen" />
<?php }elseif(MY_CUR_LANG == 'ar'){?>
<link rel="stylesheet" href="http://localhost/wordpress/wp-content/themes/arabic.css" type="text/css" media="screen" />
<?php } ?>
You cannot jump in and out php code. Try
<?php
if(MY_CUR_LANG == 'en'){
echo'<link rel="stylesheet" href="http://localhost/wordpress/wp-content/themes/style.css" type="text/css" media="screen" />';
}elseif(MY_CUR_LANG == 'ar'){
echo'<link rel="stylesheet" href="http://localhost/wordpress/wp-content/themes/arabic.css" type="text/css" media="screen" />';
}
?>
I am facing a problem . In front page of my website i got following warning: Deprecated: Function ereg() is deprecated. Yesterday it was working right. I have searched in google and got that we have to substitue with "preg_match". I did it but problem is same.
Here is the code:
<?php
/*CSS fixed for some browser*/
$browser=$_SERVER['HTTP_USER_AGENT'];
if(ereg('MSIE 6', $browser)) {
// hack IE here
?>
<link href="<?php echo JURI::base();?>/templates/crnatoday/templates/template_ie6.css" rel="stylesheet" type="text/css" />
<?
} else if(ereg('MSIE 7', $browser)) {
// hack IE here
?>
<link href="<?php echo JURI::base();?>/templates/crnatoday/templates/template_ie7.css" rel="stylesheet" type="text/css" />
<?
} else if(ereg('Safari/([0-9].[0-9]{1,2})', $browser)){
// hack safari here
?>
<link href="<?php echo JURI::base();?>/templates/crnatoday/templates/safari.css" rel="stylesheet" type="text/css" />
<?
} else if(ereg('Firefox/2', $browser) && ereg('Windows', $browser)) {
// hack firefox2
?>
<link href="<?php echo JURI::base();?>/templates/crnatoday/templates/firefox2_win.css" rel="stylesheet" type="text/css" />
<?php
} else if(ereg('Firefox', $browser) && ereg('Mac', $browser)) {
// hack firefox2
?>
<link href="<?php echo JURI::base();?>/templates/crnatoday/templates/firefox_mac.css" rel="stylesheet" type="text/css" />
<?php
} else if(ereg('Mozilla/([0-9].[0-9]{1,2})', $browser)) {
// hack mozilla here
} else {
// hack other here
}
?>
Please help to sought it out.
Your template was developed for Joomla 1.5 which supports PHP 4.3.10+. You host, has most likely upgraded the server PHP version from 5.2 or lower, to 5.3 or above.
If your template has to have separate custom CSS files for each browser, then it is a poorly made template. My suggestion would simply be to remove all that code and simply load 1 single CSS file.
If you really need to keeps these hacks (hopefully not), then have a look at the following which gives a little insight on how to convert ereg to preg_match:
http://www.devthought.com/2009/06/09/fix-ereg-is-deprecated-errors-in-php-53/
I have script which uses absolute addressing in most areas, now I need to change them to relative addressing. But then the issue I am facing here is that, if for instance I have a website named www.example.com Now I want to change the links in php from
<link href="<?php print $theme; ?>style.css" type="text/css" rel="stylesheet" />
<link href="<?php print $theme; ?>css/colorpicker.css" type="text/css" rel="stylesheet" />
to
<link href="http://www.example.com/<?php print $theme; ?>style.css" type="text/css" rel="stylesheet" />
<link href="http://www.example.com/<?php print $theme; ?>css/colorpicker.css" type="text/css" rel="stylesheet" />
But I end up getting this result
<link href="http://www.example.com/http://www.example.com/themes/in/style.css" type="text/css" rel="stylesheet" />
<link href="http://www.example.com/http://www.example.com/themes/in/css/colorpicker.css" type="text/css" rel="stylesheet" />
I know something is wrong somewhere, but I still can't get it to work.. Any help with correct formatting will be highly appreciated. Sorry if my title for question is inappropriate.
Judging by the url setup:
<?php
$path = explode('/', $theme);
$theme = end($path);
?>
<link href="http://www.example.com/themes/<?= $theme ?>/style.css" type="text/css" rel="stylesheet" />
This will split the url in pieces and picks the last item which is I think is the theme name you want.
Your $theme contains this url 'http://www.example.com/themes/in/'. So if you just want the url to be like this
http://www.example.com/style.css instead of
http://www.example.com/http://www.example.com/themes/in/style.css
then remove the $theme from the href section.
hope this helps
Their would be two possible solutions, either you remove the
http://www.example.com/
from starting of <?php print $theme; ?> OR only include
theme name rather than with base bath.
I want to load my style-sheet's and script's inside wordpress header to show documentation in my front-page/homepage for specific condition supply by wordpress option setting get_option('my_main_scripts').
Pool of values for this option setting are javascript library, javascript yui, javascript jquery, javascript dojo and so on. All option value consist with common word javascript.
and want to load css if any one value is selected from the pool which contains word javascript.
So writing condition with each option using OR (||) , I think its better to grab the common word from the value and write down the condition .here is javascript how can I get this?
<?php if ( is_home() || is_front_page() ) { ?>
<?php if (get_option('my_main_scripts') == "javascript library"): ?>
<link rel="stylesheet" href="<?php bloginfo("template_url"); ?>/css/javadoc.css" type="text/css" media="screen" />
<link rel="stylesheet" href="<?php bloginfo("template_url"); ?>/js/javadoc.dojo.css" type="text/css" media="screen" />
<link rel="stylesheet" href="<?php bloginfo("template_url"); ?>/js/javadoc.yui.css" type="text/css" media="screen" />
<link rel="stylesheet" href="<?php bloginfo("template_url"); ?>/js/javadoc.jquery.css" type="text/css" media="screen" />
<?php get_template_part('documation'); ?>
<?php endif; ?>
<?php } ?>
Use strpos.
if(strpos(get_option('my_main_scripts'),'javascript') !== false )
Also have a look at preg_match.
if(preg_match('/javascript/',get_option('my_main_scripts')))
I have to translate this code:
<!--[if IE 7]> <link rel="stylesheet" type="text/css" href="css/ie7-style.css" /> <![endif]-->
for CakePHP. At the moment I'm using $this->Html->css('fileName') in the view file and in the default.ctp I do echo $this->fetch('css');
But what do to when i must to use a conditional css expression like above?
Thanks
If you want conditionals set inside a view file (as in not in a layout), you can do:
// in your view file
$this->Html->css('file', null, array('block' => 'ie_conditional_css'));
// in layout
<?php if ($ieConditionalCss = $this->fetch('ie_conditional_css')): ?
<!--[if lt IE 8]><?php echo $ieConditionalCss ; ?><![endif]-->
<?php endif; ?>
You just put the comments around your PHP, like this:
<!--[if lt IE 8]><?php echo $html->css('filename') ?><![endif]-->