Friday, September 9, 2011

Changing the highlight color in Zend Studio/Eclipse

If you want to change the highlight color for example if you drag selections or use the find functionality.

In  Mac:
Preferences -> General -> Editors -> Text Editors -> [Appearance color options] : Selection Background Color

Thursday, September 8, 2011

NOTE: Zend Frameworks Flash Messenger

I have never used the Flash Messenger helper before so I am a little new to it. I guess I can share a couple of mishaps.

Remember when using the flash messenger if namespaces are present is to be aware to first set the namespace name BEFORE retrieving your messages.

example:
//from first controller
public function firstAction()
{
    $this->_helper->flashMessenger
                  ->setNamespace('cloudy')
                  ->addMessage('its cloudy today!');
    $this->_redirect('/second/second');
}

When retrieving this namespace dont forget to set the namespace first:
// second controller
public function secondAction()
{
   $messages = $this->_helper
                    ->flashMessenger
                    ->setNamespace('cloudy')
                    ->getMessages();
   print_r($messages);
}

Remember that if you just do:
$messages = $this->_helper->flashMessenger->getMessages();

You will not retrieve anything. Just my 2 cents since it took me a couple of minutes to figure that out.

Tuesday, September 6, 2011

Tip: Rendering a different view in another view from a different module

Say you have want to retrieve a view from another module and you have this directory structure

/modules/
    /front
        /controllers
            /front-controller-one
        /views
            /scripts
                /front-controller-one
                    /front-view.phtml
    /back
        /controllers
             /back-controller-two
        /views
            /scripts
                /back-controller-two
                    /back-view.phtml

From your controller (say you are in front-controller-one in "front" module):
$frontControllerDir = $this->getFrontController()->getControllerDirectory('back'); // retrieve controller dir of the mentioned MODULE
$this->view->addBasePath(realpath($frontControllerDir . '/../views')); // do NOT add the "scripts" dir as it will be added automatically so do NOT do this: '/../views/scripts'

The script above will add a base path of Back modules view/scripts directory to the View objects script paths so if you do print_r($this->view->getScriptPaths()) you should be able to see the new path you added above in the list.

Now from your view (/front/view/scripts/front-controller-one/front-view.phtml):
<div id="journalEntryView"><?php echo $this->render('back-controller-two/back-view.phtml'); ?></div>