CodeIgniter – Cart crap with Cyrillic characters
Ok, now this is so ridiculous that I have to blog about this even though I do not want to. CodeIgniter just blew my mind some time ago when I upgraded to 1.7.2 for the new Cart library. I realize, that it is a basic functionality, yet still... It does not support cyrillic characters in the product name! It is freaking 2009, almost 2010 and one of the most popular MVC frameworks does not support cyrillic? And I bet any other "strange" characters too, because basically they have a filter there with a regexp:
var $product_name_rules = '\.\:\-_ a-z0-9';
Now that is some serious shit!
Anyway, if you have trouble with the same thing - doing non-latin chars in product names just find and comment out the following part from system/libraries/Cart.php:
if ( ! preg_match("/^[".$this->product_name_rules."]+$/i", $items['name']))
{
log_message('error', 'An invalid name was submitted as the product name: '.$items['name'].' The name can only contain alpha-numeric characters, dashes, underscores, colons, and spaces');
return FALSE;
}
Also, if you are using a database table for your sessions - do not forget to check that the user_data field uses UTF-8 as its encoding (otherwise it won't let cyr chars into the field).
Enough ClearType! Go GDI++!
Did you ever want to replace the ugly ClearType with something better? I know I have. And my prayers have been answered - meet GDI++ - the solution to all your font problems. Enough words, see it in action (this is Verdana, btw):
Well, I think that the difference is pretty obvious. So if you are ready to start you new font life - go here and download the file named gdi0870.zip (404kb). Extract anywhere you want and launch gditray.exe. Choose 'enable' from the context menu of the tray icon and voila - your font are rendered without the help of that ugly, ugly ClearType.
Basic CSS layout
The basic CSS layout I use in my work is plain simple - header, sontent, sidebar and footer.
The HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>My page</title>
<base href="http://localhost/" />
<link rel="stylesheet" href="css/style.css" />
</head>
<body>
<div id="wrap">
<div id="header">
Header
</div>
<div id="content">
Content
</div>
<div id="sidebar">
Sidebar
</div>
<div class="clr"></div>
<div id="footer">
Footer
</div>
</div>
</body>
</html>
And the CSS is very simple:
#wrap { width: 960px; margin: 0 auto; }
#header { }
#content { width: 700px; float: left; }
#sidebar { width: 260px; float: right; }
#footer { }
.clr { clear:both; height:0px; overflow:hidden; }
This is it. This code will show a simple page which is ready for hardcore modification. I know this is pretty basic yet it is one of the most used code snippets in my IDE. Good luck!
Image / file upload with CodeIgniter
Image upload can be a pain in the *ss. And even though CI has a lot to offer (in the means of documentation) it still lacks a direct copy-paste code on their website so that people can just put it into their controller and use away.
Here we will have:
- Image upload form with 5 images
- And a controller function that will upload those
- Thumbnails will be there too
Komodo Edit tools – add style.css and reset.css
Good morning, planet. Today I am going to share a very useful script I am using in Komodo Edit (it automates adding style.css). It is very (!) simple yet very effective for me and, probably for others who are doing a lot of HTML files and face a problem of repetitive actions.
This thing works as follows (the use case):
- You create a new HTML file in komodo and save it in some directory.
- You double-click the script in the Komodo Edit toolbox.
- The script adds the following folders/files to the project (paths relative to the file currently in editor!)
- css/
- css/style.css
- css/reset.css
- Also the file adds the following HTML code at the cursor in current opened file:
Voila. The needed action is done.
How-To: Create a horizontal menu
This is a tutorial on how to create a fully costomizable horizontal menu. Why another menu how-to? Well, mostly because there are situations when there are no suitable google results (based on my experience) and you have to come up with something yourself.
These are the features we will try to get into our menu:
- It will be horizontal
- It will have splitters (made with images)
- It will have active class for rollover / selected item (background change)
- Menu items will be of different size
This code works for Internet Explorer 6+, Firefox 2.0+, Opera 9+, Safari (at least on Safari 4 - tested on Windows version of it).
Here is a mockup that we have:
Menu mockup
NB! If you just want to see how to do it - go here for the demo / full code.
Web development future
As you may already know I work as a web developer. This means I encounter a lot of (X)HTML, PHP and JavaScript. There is no doubt that those are the most widely used tools for small/medium websites as well as there is no doubt that with all the new trends, with the increasing will to build the "Web 2.0" the developmet becms harder and harder. There is a tremendous amount of ways to implement things, a huge number of frameworks out there than say "Hey, use me! I am the best!". Obviously, this is very stressful for the developer. And what is more stressing is the complexity of the code.
Remember how you used to write those small pure HTML pages without caring about whether it passes the validity tests? Remeber how you didn't care about Mozilla, Opera and Safari? You only had to make sure that this will work in IE and put a small text on the front page - "This site was made for IE6".
After that came PHP, which was overwhelming. It is a great tool designed to make scripting pages with ease. Then came databases and object-oriented paradigms. That is the time when I first started to feel frustrated. The code did not fit into my head anymore. I had to review the classes I have, the functions that they have, members, deal with connections and other crap.
And the latest thing - AJAX. This thing has been terrorising every single web developer. When I hear AJAX I always have two conflicting feelings - it is cool and it is very unpleasant to make it happen. I mean JavaScript was so simple (and mostly unnecessary) until AJAX hit the internet (and Web 2.0, of course). All you did was getElementById and validate forms with it sometimes.
Where am I going with this? Well... It is simple. At the moment the whole web development process with HTML/PHP/JS is quite complicated if you want to make something exceptional. As I work I keep seeing that I am performing repeating actions now and then. And I think that now it is time to make something new. A new way, a new tool, tailored for the specific needs of the web developer community. I will be not surprised if it will be something ASP.NET-like. Let it be. It is time to either dramatically improve the web development tools we have now or to create a new all-in-one tool that takes the concepts of HTML, PHP and JS/AJAX together and puts them into a universal form.
Web development tools I use and recommend
Ok, not being original here, but still... a web developer's blog is never complete without this. Maybe somebody will find at least something useful here. So here goes:
Tasks
- slicing designs into images and cobining it to (X)HTML/CSS
- script writing (PHP / JavaScript)
- debugging
- testing IE compatibility
- quick editing
- database handling
- OS: Microsoft Windows
- others
A bit of MODx CMS criticism
Today I am going to talk about MODx CMS again. Now, the first post on this topic covered my first impressions of this product. And now I have something else to say.
This time I am going to go a bit deeper into minuses of MODx. Why? Well, all the pluses are available on the official website and I do not see the reason for repeating those. This post does not in anyway mean that MODx is a bad product! It just has some bad sides that I would find very useful to read about before starting to build a website based on this system. This post is healthy citicism and maybe a precaution for those wondering what can't you do with MODx.
