Archive for CakePHP

CakePower embed CssMin to minfy CSS on the fly!

Hi CakePowers!
today I embed CssMin utility into CakePower plugin to minify your CSS on the fly.

This is a zero-configuration add-on and works with Less compiler layer to offer the best way to write CSS for your pages and applications!

When your Configure::read('debug') is set to “0″ value any compiled LESS source is minified  to offer the smallest possible footprint for your styles assets.

Posted in CakePHP | Leave a comment

PowerMenu Helper – how to build menus with CakePower

PowerMenuHelper offers an easy way to generate HTML from PowerMenu‘s data:

// PowerMenu Helper in Action:
echo $this->PowerMenu->generate('sidebar.menu');

Continue reading »

Posted in CakePHP | 1 Comment

CakePHP: Using View Blocks – The CakePOWER way!

View Blocks allow to add content to a logic container during page rendering.

At the end of the story a layout, a view or an element may display some contents fetching it from a container using container’s name.

CakePOWER supplies an helper method to quickly create DOM blocks form View Blocks:

echo $this->Html->block( 'block_name' );

Continue reading »

Posted in CakePHP | 3 Comments

CakePower Events API

CakePower triggers lots of events while performing it’s logic so you can write some listeners and inject logic and code into altering the standard flow of the application.

This post describe each event triggered by CakePower, it’s properties and available returning values.

Continue reading »

Posted in CakePHP | Leave a comment

How to use RequireJS with CakePHP – CakePOWER

RequireJS is a library created to load js files asynchronous. It’s objective is to optimize developement and speed up the web page.

I do not cover any RequireJS documentation here. Let me say it ask you to write a piece of code like this in your HTML:

<script src="path/to/require.js" data-main="path/to/script"></script>

where the “src” attribute points to the RequireJS library and the “data-main” attribute points to the main script to be loaded. This is the entry point of your js app and here you can load other modules (AMD).

The problem: “data-main” needs a relative path to the document so you need to write a CakePHP piece of code like that:

// do you really want to write this code??
echo $this->Html->script( 'path/to/require', array(
    'data-main' => $this->Html->assetUrl( 'path/to/script', array(
        'pathPrefix' => JS_URL, 
        'ext' => '.js'
    ))
));

this way the data-main attribute will contain the correct url to the js folder.

CakePower supplies a really easy solution to write above code in a compact and simple way:

// With CakePower loaded into your CakePHP app:
echo $this->Html->script( 'path/to/require', array(
    'data-main' => 'path/to/script'
));

Easy, isn’t it?

Posted in CakePHP | Leave a comment

CakePower embed LESS to improve CSS developement!

Hi CakePowers!
Today I have a very nice update for you!

I read about Hyra Less CakePHP plugin who embed LessC, a PHP compiler for Less.

CakePower now embeds LESS  to enhance CSS developement in your projects!

 

Simplicity in mind!

With simplicity in mind CakePower embeds Hyra’s logic and LessC library to use Less the easiest possible way:

  1. Create your .less sources in your /app/webroot/less/ folder
  2. Use it in your layout as you already do with HtmlHelper
No changes to your work-flow are required!
Posted in CakePHP | 2 Comments

CakePHP Tree Behavior Ordering Issue

Today I found a simple issue with CakePHP’s Tree Behavior.

When saving a model with an empty parent_id Tree Behavior recalculates left and right node.

The consequence is to alter an existing order putting the record at the end of the list.

This problem manifests only with root items with an empty parent_id. Sub trees are safe from this issue!

Continue reading »

Posted in CakePHP, Tips & Tricks | Leave a comment

How to create a quick menu in your view

Quick Menu is a very simple way to change the scope of an admin action with a click.

If you are editing a user profile you are doing something like:

  • controller: users
  • action: edit
  • scope: 53 (the user’s id)

When you need to switch to another user profile you need to change the scope of your action, not the action itself so a little jump menu may be the really easiest way to perform this action.

Continue reading »

Posted in CakePHP | Leave a comment

CakePHP: shared hosting production folder structure

Today I want to share with you a simple folder configuration I use to install a CakePHP project to a shared hosting.

CakePHP’s default folder structure:

CakePHP comes with this folder structure

  • CakePHP/
  • app
  • Controller
  • Model
  • webroot
<li>libs</li>

You should configure your web server to use CakePHP/app/webroot/ as root.

This way all your php and temporary files stay out of the url access capabilities. This is a security best pactice… but you can’t do that in a shared hosting!

I really think there may be a better way… and i’ve got it!

Continue reading »

Posted in CakePHP | Leave a comment

Automagically AjaxForm speeds up your App!

Today I’ve been working on UI optimization for my CakePanel plugin: Ajax Forms.

Ajax is often used to speed up an application when sending forms: with AJAX the client’s browser does not need to re-load the page, just send data to the already opened HTTP channel and get some data back.

CakePanel provides two methods to implement AjaxForm: explicit javascript configuration and the automagically way!

Continue reading »

Posted in CakePHP | Leave a comment

Swedish Greys - a WordPress theme from Nordic Themepark.