RSS
 

Archive for January, 2009

CakePHP: jQuery styling of flash messages

30 Jan

CakePHP session flash messages is one of the most useful things for usability, and user notification. Trying to make it more fancy, I came to jQuery framework with its HighlightFade plugin.

Adding just a couple of lines, we can get nice effects, looking the same as WordPress messages in Posting/Editing:

      var $j = jQuery.noConflict(); //I'm using Prototype as well, so we don't need conflicts
$j(document).ready(function() {
       if( $j("#flashMessage") ){ 
          $j("#flashMessage").highlightFade({color:'#24F273',speed:2000, iterator:'exponential'});
       }
});

Thus, next time you will pass $this->Session->setFlash('Foo');, your flash message with default

<div id="flashMessage"><?php $session->flash();?></div>

will be used with above HighLight effect.

 

Learning C++ as new language

07 Jan

Quite interesting article from Stroustrup (unfortunately dated by 1999), however still topical. Here is a small list of concepts a person should be considered. The the approach to a new language, which:

– proceeds from the concrete to the abstract,
– presents language features in the context of the programming and design techniques that they exist
to support,
– presents code relying on relatively high-level libraries before going into the lower-level details (nec-
essary to build those libraries),
– avoids techniques that do not scale to real-world applications,
– presents common and useful techniques and features before details, and
– focus on concepts and techniques (rather than language features).

As well, as some interesting comparisons of C and C++ languages in his article.

 

CakePHP: named over url parameters passing

05 Jan

Playing around with CakePHP parameters passing through URL, I’ve noticed that using Paginator helper for listing entities mixes up named and url params in the URL.

For instance, classical paginator URL is:

http://domain.com/controller/action/page:number


which looks like:

Array(
[named] =>Array(
[page] => number
)
)

Any parameter used in the Paginator goes inside of the URL and doesn’t affect the behaviour (in my case, URL param is used for language switching), i.e. http://domain.com/controller/action/?param=foo/page:number
No matter what your $this->params['url']['param'] contains – it won’t reflect on the logic.
Thus, if we use another variable $this->params['named']['foo'], we can always access it in our viewers and utilize it in the $paginator variable, so our URL will look like:
http://domain.com/controller/action/page:number/foo:bar
Useful links:
Additional parameters in $paginator