Probably everybody know how to match dom elements with css. For example if you want to match all <li> elements. you are doing something like this:
This way every list element will have red text color.
The more advanced example is if you want to select only the active element – an element with a specific class. This way you are adding a style like:
This way only the active elements (list elements with class active) will have red text color.
Ok, but what if we want to match elements which has 2 specific classes?
Let’s say you have following structure:
How to make the first list element to be with red color?
The obvious solution is to add an extra class like this:
but what if there is an easiest solution?
<li class="first second"
As you may notice the css selector which is used is .first.second, so no spaces between them.
This way you can assure that only the element which has class first and second will meet the criteria and will be colorized in red. This notation works with ID’s as well, but basically if you have ID, then you know what is the exact element, so it’s useless, but for selection of two classes I think it really useful.
I would like to know if somebody knew about this way of selecting elements?
I am using it for a while, but today I’ve decided to publish in the github.com.
What this plugin does?
The plugin is complete solution to add menu in your applications. It uses the nifty Superfish – jQuery menu plugin. You can find more info for it at http://users.tpg.com.au/j_birch/plugins/superfish/
Cakemenu can work with multilevel menus and reduces the database calls by caching the menu nodes. The plugin working with Authake plugin if you need to apply filter to menu nodes (user need to see only allowed locations)
Cakemenu working with CakePHP 1.2 but it’s tested with Cakephp 1.3 (RC3) and it would not have any problems with the future releases so far.
- CakePHP 1.3 (of course)
- jQuery in the head tag
- Authake (optional) if you require your menu nodes to be filtered when user with limited privileges is logged in. Actually it’s possible to use other authorization class, but you have to extend it.
I believe that’s it. Check the large README file in the project’s directory.
Finally the Authake Plugin have an Installation guide.
Basically the plugin provide Authentication and Authorization functionality for CakePHP’s appliation with few line of code. Authake has advanced User-Group-Role interface and allow you to secure your CakePHP’s application within a minute.
The current version of the Plugin is “wrapped” in a single folder (according to CakePHP 1.3 conventions) under the Plugins.
Update: This plugin has been addapted for CakePHP 2.0 by Mutlu Tevfik Kocak. Please use his repository for actual version of the plugin. https://github.com/mtkocak/authake
Working on a project I had following problem.
I had to set isUnique validation of a field. The field has VARCHAR(10) type. When I save the data the “isUnique” validation doesn’t work as expected while I was sure that the there is such record in the database. Digging through the problem it turn out that the problem is in the length of the DB column.
Let me explain. The field was length 10, but in the form I’ve put the value which is 11 characters long, so when the first data is submitted instead of the 11 characters, only 10 are saved in the DB table. My value was 456-23-2010 while in the db it’s saved 456-23-201.
So when inserting the new data the script checks 456-23-2010 against the database where is stored 456-23-201. and of course it passes the validation. While on the edit action strangely it appear that the value it is not unique any more (because there are already 2 records 456-23-201 in the db. 🙂
A little bit tricky, because at first glance the data is almost the same. For sure if the inserted string was large than the saved in the DB I would spot it easily, but to me the number was really the same.
There are 2 possible ways where I would think how to solve this problem in the future: Either modifying the Bake template for my applications, or using better validation technique – where the value is trimmed up to length of the field.
I was wondering what would be the better way?
I’ve just updated the wordpress plugin called Autocompleter with a new version.
From now on you can change the type of the results in the autocomplete options. The available options are:
- Categories and Tags (default)
- Tags only
- Categories only
- Posts and Pages titles
- Posts titles only
- Pages titles only
Result types can be changed from the admin page of the plugin.
The change has been made, because there were many requests for such types of results and I finally decided to implement them in the official version of the plugin.
If you use it already, just press upgrade automatically, or visit the official page of the plugin.
I just want to present a new tool for converting HTML to PDF – html-2-pdf.com. It’s basically an online converter which could transform any* web site to a PDF document. Generally it could be useful if you want to print a website, or for example if you want to save the content of the website for offline reading.
The site is really simple – just insert the address of the web page which you want to be converted and few seconds after that it is ready to be downloaded. The site is just an interface of the amazing wkhtmltopdf library.
I am open for suggestions about the functionality of the site.
* – for some reasons there are web sites which are not converted correctly. This is because of HTTP headers which these sites restricting.
When you building application most likely there are common links within the layout. They could be in a menu, or let’s say “edit profile” and ‘logout’ links which are visible everywhere. As you probably know if you use Html Helper the link could be either Cake-relative URL or array of URL parameters.
The problem may occur if you using the second option – the array.
Sometimes you need to use url() in the controller.
It’s possible to use Html Helper in this case, but for url() only, you can use:
Router::url(array('controller'=>'my_controller', 'action'=>'my_acton'), false);
Wll, not a rocket science indeed, but let’s hope this help someone.
Today I was working on a page layout where a page width had to be fluid, while the sidebar had to be with fixed width. So here is my solution:
The layout looked like this in the beginning:
When building applications is always smart to check and clean the user input. This is a must when you building a website or public application.
I create always an instance of Sanitize class in my AppController and then using it in all of my controllers like this