I collated a list of the languages (ISO-639-2) and the direction they are most commonly written in and provided it as a TXT or CSV file for download here: https://github.com/webmasterar/languagesWithDirections
Examples:
ara,,ar,Arabic,arabe,rtl
chi,zho,zh,Chinese,chinois,ttb
eng,,en,English,anglais,ltr
This is mostly useful with the correctly displaying text on websites using the HTML bdo tag or CSS styles direction and/or writing-mode.
Showing posts with label CSS. Show all posts
Showing posts with label CSS. Show all posts
Friday, 29 April 2016
Saturday, 25 June 2011
Loading CSS, JS and images from CodeIgniter
Just a quick tip for newbs (me included). If you're having trouble loading css, js or image files into your views/templates in CodeIgniter and you do a Google search to find the solution, you'll find many websites telling you to use the base_url() function. This didn't work for me!
The reason why it didn't work was because I hadn't loaded the url helper class... DUH! Stick this in the constructor of your controller or autoload it in your autoload.php configuration file.
$this->load->helper('url');
Now you can use the base_url() function to get the url path from where to look for those files, e.g.:
This will load a css file called main.css from a folder called styles which is just under the base url folder codeigniter. On my PC it will find the file from: C:\wamp\www\codeigniter\styles\main.css
I reckon the creators of CodeIgniter should have added a constant through which to refer to the base_url and similar paths, or at least make the url class have static functions so url::base_url() can be called instead of base_url() which could be confused for a normal PHP function.
The reason why it didn't work was because I hadn't loaded the url helper class... DUH! Stick this in the constructor of your controller or autoload it in your autoload.php configuration file.
$this->load->helper('url');
Now you can use the base_url() function to get the url path from where to look for those files, e.g.:
<link rel="stylesheet" href="<?php echo base_url(); ?>styles/main.css" type="text/css">
This will load a css file called main.css from a folder called styles which is just under the base url folder codeigniter. On my PC it will find the file from: C:\wamp\www\codeigniter\styles\main.css
I reckon the creators of CodeIgniter should have added a constant through which to refer to the base_url and similar paths, or at least make the url class have static functions so url::base_url() can be called instead of base_url() which could be confused for a normal PHP function.
Thursday, 24 September 2009
Kohana PHP framework - some tips
Recently, I've been working with the Kohana PHP Framework and there are a few hurdles I've come across and gotten past - here are a few tips.
Making your own Controller
The default gateway controller with a fresh install of Kohana is 'welcome'. This means that URIs are written a bit like this:
http://localhost/kohana/welcome/index
But it's not ideal to have 'welcome' in the URI all the time. So, if you want to choose a custom name like 'site', you need to make your own controller...
<?php html::anchor('site/index', 'Home Page'); ?>
Making your own default template
Simply go to /kohana/system/views/kohana/ and copy the template.php file to /kohana/application/views/kohana/. Edit the file as you wish. But, make sure your controller has this line pointing to it: public $template = 'kohana/template';
Making your CSS and Javascript work (get found)
So you make your XHTML template file and are ready to test everything - you stick your CSS in a .css file and your Javascript into a .js file and your images into an 'images' folder and put them in the root (/kohana/). You go to the page through the URI, e.g. http://localhost/kohana/site/index
Huh? What's this? Your CSS, Javascript and image files were not found!
Turns out you need to change the location of your files and add some PHP to your template.
html::script(array('media/js/js'), FALSE); ?>
Now this will put the typical XHTML tags into your page to include outside css and js files:
Making your own Controller
The default gateway controller with a fresh install of Kohana is 'welcome'. This means that URIs are written a bit like this:
http://localhost/kohana/welcome/index
But it's not ideal to have 'welcome' in the URI all the time. So, if you want to choose a custom name like 'site', you need to make your own controller...
- Copy the welcome controller (welcome.php) in /kohana/applications/controllers/ and paste into the same folder.
- Rename the file to site.php
- Open the site.php file and change the class declaration to 'class Site_Controller extends Template_Controller'
- Now, go to /kohana/system/config/ and copy the file called routes.php to /kohana/application/config/ .
- Open up the file and edit like so: $config['_default'] = 'site';
<?php html::anchor('site/index', 'Home Page'); ?>
Making your own default template
Simply go to /kohana/system/views/kohana/ and copy the template.php file to /kohana/application/views/kohana/. Edit the file as you wish. But, make sure your controller has this line pointing to it: public $template = 'kohana/template';
Making your CSS and Javascript work (get found)
So you make your XHTML template file and are ready to test everything - you stick your CSS in a .css file and your Javascript into a .js file and your images into an 'images' folder and put them in the root (/kohana/). You go to the page through the URI, e.g. http://localhost/kohana/site/index
Huh? What's this? Your CSS, Javascript and image files were not found!
Turns out you need to change the location of your files and add some PHP to your template.
- make a folder in root (/kohana/) called 'media'.
- make 3 folders called images, css and js inside your media folder and move your images, css and javascript files into their respective folders
- Edit your css and js files to point to the right path for the images, e.g: background-image: url(/kohana/media/simages/bg.png); (make sure the first / is there otherwise it won't work
- Now edit your template file to include this bit of code in the head section (I called my css file and js file css.css and js.js (imaginative huh?)):
html::script(array('media/js/js'), FALSE); ?>
Now this will put the typical XHTML tags into your page to include outside css and js files:
<link rel="stylesheet" type="text/css" href="/kohana/media/css/css.css" media="screen" />
<script type="text/javascript" src="/kohana/media/js/js.js">