logo

Only showing active records – model wide conditions cakePHP

logo

I know its been a bit of a whole since my last update but have a bit of useful info here:

 function beforeFind(&$queryData)
	{
	    $conditions = $queryData['conditions'];

	    if (!is_array($conditions)) {
	        if (!$conditions) {
	            $conditions = array();
	        } else {
	            $conditions = array($conditions);
	        }
	    }

	    if (!isset($conditions['active']) && !isset($conditions[$this->alias . '.active'])) {
	        $conditions[$this->alias . '.active'] = 1;
	    }

	    $queryData['conditions'] = $conditions;
	    return true;
	}

Put this in the model that you have an ‘active’ field in and it will save you having to add a condition into each find statement to check whether that record is flagged as active / inactive!

Share with your friends and help out this site:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogosphere News
  • E-mail this story to a friend!
  • Identi.ca
  • LinkedIn
  • Live
  • MisterWong
  • MySpace
  • Ping.fm
  • Reddit
  • RSS
  • Slashdot
  • StumbleUpon
  • Suggest to Techmeme via Twitter
  • Technorati
  • Tumblr
  • Twitter
  • Yahoo! Bookmarks
  • Yahoo! Buzz

CSS Sprites – Why they are cool and A tool to make it easier

logo

I’ve been experimenting with CSS sprites as of late, I’m half way through this project now so there seems little point in introducing them at this point. Basically speaking a CSS Sprite is a bunch of images amalgamated into a single image that you then use CSS and the :hover etc functions associated to links to move different parts of that image into view (Tabs would be an ideal example of this).

e.g.:
CSS Sprite

Anyway I found this very cool site that explains a lot more about it and it provides a cool tool to help you merge your own CSS sprites.

http://css-tricks.com/css-sprites/

Share with your friends and help out this site:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogosphere News
  • E-mail this story to a friend!
  • Identi.ca
  • LinkedIn
  • Live
  • MisterWong
  • MySpace
  • Ping.fm
  • Reddit
  • RSS
  • Slashdot
  • StumbleUpon
  • Suggest to Techmeme via Twitter
  • Technorati
  • Tumblr
  • Twitter
  • Yahoo! Bookmarks
  • Yahoo! Buzz

Web Developer Toolbar comes to Chrome at last!

logo

I know, I know – I have not updated this thing in a while, to be honest it is mainly because I have been doing less and less developement in my main job as of late and more trying to sure up the internal infrastructure to somewhere near safe.

But here is a quality update for you – The Web Developer Toolbar has finally come to Chrome, so if you are like me – love Chrome, and tiring of Firefox’s slowdowns, memory leaks, random Crashes and its complete inability to handle multiple flash videos – AND – you are a webdeveloper – I guess now is the time to switch.

I hope this helps! :)

Share with your friends and help out this site:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogosphere News
  • E-mail this story to a friend!
  • Identi.ca
  • LinkedIn
  • Live
  • MisterWong
  • MySpace
  • Ping.fm
  • Reddit
  • RSS
  • Slashdot
  • StumbleUpon
  • Suggest to Techmeme via Twitter
  • Technorati
  • Tumblr
  • Twitter
  • Yahoo! Bookmarks
  • Yahoo! Buzz

Inserting non web safe fonts into pages

logo

It has been a bit of a pain to do this until recently, sIFR was the main way of doing it which basically used flash to render the font – however I have recently come across this which just uses Javascript to do it and no flash – take a look and see what you think:

http://wiki.github.com/sorccu/cufon/about

Share with your friends and help out this site:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogosphere News
  • E-mail this story to a friend!
  • Identi.ca
  • LinkedIn
  • Live
  • MisterWong
  • MySpace
  • Ping.fm
  • Reddit
  • RSS
  • Slashdot
  • StumbleUpon
  • Suggest to Techmeme via Twitter
  • Technorati
  • Tumblr
  • Twitter
  • Yahoo! Bookmarks
  • Yahoo! Buzz

Housekeeping

logo

Apologies again for the lack of updates – has been a bit hectic here and as I havent really been doing any coding, I havent had much useful information.

So today I thought I would share some Linux Pearls of wisdom, many people need to create housekeeping scripts that clean up certain directories every so often.

Many Perl advocates will tell you that banging a load of Regex into perl will do it simply.

I disagree – POSIX gives you plenty of tools to do 99% of the tasks you need – its just a case of knowing which ones you should be using.

To get you started here are 2 of the most used:

find /your/dir/here -mtime +30 -exec ls {}\;

Lists all files modified more than 30 days ago (clearly you can replace ls with rm to delete these!)

find ./ -type f -atime +365

This finds any files that havent been access for over a year, obviously you can pipe / exec this with something else.

Hope this helps!

Share with your friends and help out this site:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogosphere News
  • E-mail this story to a friend!
  • Identi.ca
  • LinkedIn
  • Live
  • MisterWong
  • MySpace
  • Ping.fm
  • Reddit
  • RSS
  • Slashdot
  • StumbleUpon
  • Suggest to Techmeme via Twitter
  • Technorati
  • Tumblr
  • Twitter
  • Yahoo! Bookmarks
  • Yahoo! Buzz

« Previous Entries Next Entries »

logo
Powered by Nu Order Webs