Change style.css by changing language in php - php

Does anyone know how to use condition in CSS?
I'm using PHP Script The thing is that I have 4 files with these names "style.css","style-rtl.css","bootstrap.min.css","bootstrap-rtl.min.css" that sometimes may be in RTL language.
So I want some sort of PHP code or any other solution that can detect if the language is Ar and set the direction to RTL with style-rtl.css & bootstrap-rtl.min.css , else language is En set direction to LTR and use style.css & bootstrap.min.css .
Here is some header.php code:
<!-- Bootstrap core CSS -->
<link href="<?php echo $this->config["url"] ?>/static/css/bootstrap.min.css" rel="stylesheet">
<link href="<?php echo $this->config["url"] ?>/static/css/bootstrap-rtl.min.css" rel="stylesheet">
<!-- Component CSS -->
<link rel="stylesheet" type="text/css" href="<?php echo $this->config["url"] ?>/themes/<?php echo $this->config["theme"] ?>/style.css">
<link rel="stylesheet" type="text/css" href="<?php echo $this->config["url"] ?>/themes/<?php echo $this->config["theme"] ?>/style-rtl.css">
<link rel="stylesheet" type="text/css" href="<?php echo $this->config["url"] ?>/static/css/components.min.css">

i solved this problem with :
<?PHP
if(isset($_SESSION['lang']))
{
switch($_SESSION['lang']):
case 'eng':
// LTR Style
?>
<link href="<?php echo $this->config["url"] ?>/static/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="<?php echo $this->config["url"] ?>/themes/<?php echo $this->config["theme"] ?>/style.css">
<?PHP
break;
case 'ar':
// RTL Style
?>
<link href="<?php echo $this->config["url"] ?>/static/css/bootstrap-rtl.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="<?php echo $this->config["url"] ?>/themes/<?php echo $this->config["theme"] ?>/style-rtl.css">
<?PHP
break;
default:
?>
<link href="<?php echo $this->config["url"] ?>/static/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="<?php echo $this->config["url"] ?>/themes/<?php echo $this->config["theme"] ?>/style.css">
<?PHP
endswitch;
}
?>

Related

Change default style based on title

I am trying to change the default style based on title of the page.I found that as the easiest way to accomplish needs.
I load the default styling option in header.php file:
<link rel="stylesheet" data-them="" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="all" />
I suppose <?php bloginfo('stylesheet_url'); ?> loads style.css which is on same path as header.php
I commented out this the line <link rel="stylesheet" data-them="" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="all" /> and tried to check title with php, based on that condition I wanted to load different style.css file.
<?php
$title = get_the_title();
if($title === "Title1"){
?><link rel="stylesheet" data-them="" href="style.css" type="text/css" media="all" /><?php
}
elseif($title === "Title2"){
?><link rel="stylesheet" data-them="" href="style2.css" type="text/css" media="all" /><?php
}
else{
?><link rel="stylesheet" data-them="" href="style3.css" type="text/css" media="all" /><?php
}
?>
This code does not work for me and not sure why.. Styling is messed up
Please find below style in your theme. Mostly enqueue in functions.php file.
EX:
wp_enqueue_style( 'twentynineteen-style', get_stylesheet_uri(), array(),
wp_get_theme()->get( 'Version' ) );
Please add below line after your theme's default style.
(get_stylesheet_uri())
wp_dequeue_style('twentynineteen-style');
After that check it your issue.
Please dequeue default style using below function.
wp_dequeue_style('default-style');

when redirected to a page the css files , js , images etc aren't loading

I am new in codeigniter. actual page has no problems but when redirected to a page the css files , js , images etc aren't loading
<script src="<?php echo site_url('resource/js/bootstrap.js'); ?>"></script>
<link href="<?php echo site_url('resource/css/default.css'); ?>" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href=" <?php echo site_url('resource/css/tab.css'); ?>" type="text/css" media="screen">
<link rel="stylesheet" href="<?php echo site_url('resource/css/mob.css'); ?>" type="text/css" media="screen">
<link href="<?php echo site_url('resource/css/nav.css'); ?>" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="<?php echo site_url('resource/css/style.css'); ?>" type="text/css" media="screen" />
<link rel="stylesheet" href="<?php echo site_url('resource/font/font.css'); ?>" type="text/css" media="screen">
I think you have to replace site_url() with base_url()
echo base_url(); // http://example.com/website
echo site_url(); // http://example.com/website/index.php

why does my css nor html load in codeigniter?

When I include the following code within my view file:
<link rel="stylesheet" href="<?php echo base_url();>css/libs/animate.min.css" type="text/css" media="all">
<!-- Font Awesome icon library -->
<link href="<?php echo base_url();?>css/libs/font-awesome.min.css" rel="stylesheet" type="text/css" media="all">
<!-- Load primary stylesheet -->
<link rel="<?php echo base_url();?>stylesheet" href="css/skin.css" type="text/css" media="all">
Nothing loads not even HTML content,
but when I remove these lines HTML content loads properly.
So how do I load my CSS files? They are in my assests/css
You have to load helper in config/autoload.php
$autoload['helper'] = array('url', 'file','form');
in config.php]
$autoload['helper'] = array('url');
and base_url() should
$config['base_url'] = '';
you did mistaken to close the php script in first css linking
you wrote .
<?php echo base_url();>
instead of
<?php echo base_url();?>
and also check that you have loaded url helper in your code or not ?
use this
<link rel="stylesheet" href="<?php echo base_url();?>css/libs/animate.min.css" type="text/css" media="all">//mistake in this line missing '?'
<!-- Font Awesome icon library -->
<link href="<?php echo base_url();?>css/libs/font-awesome.min.css" rel="stylesheet" type="text/css" media="all">
<!-- Load primary stylesheet -->
<link rel="<?php echo base_url();?>stylesheet" href="css/skin.css" type="text/css" media="all">

joomla 1.5 Custom mobile framework not loading css

Hi Guys I have been tasked with moving a custom framework from joomla 1.5 to 3.0 I have gotten the framework to load the homepage perfectly however when I go to other pages the css wont load here is the code:
PHP:
<link rel="stylesheet" href="<?php echo $this->baseurl(); ? >templates/system/css/system.css" type="text/css" />
<link rel="stylesheet" href="<?php echo $this->baseurl(); ?>templates/system/css/general.css" type="text/css" />
<link rel="stylesheet" href="<?php echo $this->templateurl(); ?>/css/addons.css" type="text/css" />
<link rel="stylesheet" href="<?php echo $this->templateurl(); ?>/css/layout.css" type="text/css" />
<link rel="stylesheet" href="<?php echo $this->templateurl(); ?>/css/template.css" type="text/css" />
<link rel="stylesheet" href="<?php echo $this->templateurl(); ?>/css/typo.css" type="text/css" />
HTML Output:
<link rel="stylesheet" href="http://flyvail/index.php/templates/system/css/system.css" type="text/css" />
<link rel="stylesheet" href="http://flyvail/index.php/templates/system/css/general.css" type="text/css" />
<link rel="stylesheet" href="http://flyvail/index.php/templates/FlyVail2/css/addons.css" type="text/css" />
<link rel="stylesheet" href="http://flyvail/index.php/templates/FlyVail2/css/layout.css" type="text/css" />
<link rel="stylesheet" href="http://flyvail/index.php/templates/FlyVail2/css/template.css" type="text/css" />
<link rel="stylesheet" href="http://flyvail/index.php/templates/FlyVail2/css/typo.css" type="text/css" />
<!-- CSS for handheld devices -->
<link rel="stylesheet" href="http://flyvail/index.php/templates/FlyVail2/css/handheld/layout.css" type="text/css" />
<link rel="stylesheet" href="http://flyvail/index.php/templates/FlyVail2/css/handheld/template.css" type="text/css" />
<!-- CSS for handheld devices -->
<link rel="stylesheet" href="<?php echo $this->templateurl(); ?>/css/handheld/layout.css" type="text/css" />
<link rel="stylesheet" href="<?php echo $this->templateurl(); ?>/css/handheld/template.css" type="text/css" />
<!-- //CSS for handheld devices -->
I am not sure why it isn't loading right
Assuming this is in your template's index.php file, then try:
$doc = JFactory::getDocument();
$doc->addStyleSheet($this->baseurl.'/templates/'.$this->template . '/css/NAMEOFSTYLESHEET.css', $type = 'text/css', $media = 'screen,projection');
to add your style sheets instead.
My guess is that $this->baseurl() does not work with the () as it is a parameter, not a function. As such, your link is shown without the baseurl is generated by a relative link which also takes into account the base href that joomla sets. This means when you are not in the root of the site, it the link is wrong.
(Your code would probably work if you just removed all the ()s, but the addStyleSheet method is better practise)
If that doesn't work, can you take a look to see if the URL generated is different on your homepage where you say it works and the sub-page where you say it does not, and add this additional info to your question.

Wordpress: Special css for TWO Pages

In my blog i have two sites, that need a special css. For the site "projects" i did this:
<?php if ( is_page('projects') ) { ?>
<link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/projects.css" type="text/css" media="screen" />
<?php } else { ?>
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
<?php } ?>
This works like a charm.. but i also need a special css for the home..
How can i do that..? if i just put:
<?php if( is_home() ) { ?>
<link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/home.css" type="text/css" media="screen" />
<?php } ?>
Above the other code, it will not work..
The whole code i use now is:
<?php if( is_home() ) { ?>
<link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/home.css" type="text/css" media="screen" />
<?php } ?>
<?php if ( is_page('projects') ) { ?>
<link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/projects.css" type="text/css" media="screen" />
<?php } else { ?>
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
<?php } ?>
Thanks for your help - and sorry for my english !
You should do:
<?php if(is_front_page()) { ?>
// html code here
<?php } else if ( is_page('projects')) { ?>
// html code here
<?php } else { ?>
// html code here
<?php } ?>

Categories