Joey Adams Dot Net

Southern Fried Programming


Archive for the ‘Zend Framework’


Breadcrumbs with Zend Framework

I was integrating breadcrumbs into a site I am currently building and figured I would share the code I used to make it possible.

This project uses a MODULAR layout, so theres no solutions out there that helped me out. I wanted it to display cleanly, without displaying things like ‘default’ as the module name, and not to display a breadcrumb if it was the home page (ie. default module, index controller, index action).

 Basically it is a view helper that you call, and it fetches everything for you.

Some things to know. It pulls  ’siteurl’ from the Zend_Registry, you can change this if you want, well you can change anything you want, it’s nothing special, but it may help someone out there.

 Just add this viewhelper

<?php

/**
* BreadCrumb View Helper
*@author Joey Adams
*
*/
class ViewHelpers_BreadCrumb {

public function breadCrumb() {
$module = Zend_Controller_Front::getInstance()->getRequest()->getModuleName();
$l_m = strtolower($module);

$controller = Zend_Controller_Front::getInstance()->getRequest()->getControllerName();
$l_c = strtolower($controller);

$action = Zend_Controller_Front::getInstance()->getRequest()->getActionName();
$l_a = strtolower($action);

// HomePage = No Breadcrumb
if($l_m == 'default' && $l_c == 'index' && $l_a == 'index'){
return;
}

// Get our url and create a home crumb
$url = Zend_Registry::get('siteurl');
$homeLink = "<a href='{$url}/'>Home</a>";

// Start crumbs
$crumbs = $homeLink . " > ";

// If our module is default
if($l_m == 'default') {

if($l_a == 'index'){
$crumbs .= $controller;
} else {
$crumbs .= "<a href='{$url}/{$controller}/'>$controller</a> > $action";
}
} else {
// Non Default Module
if($l_c == 'index' && $l_a == 'index') {
$crumbs .= $module;
} else {
$crumbs .= "<a href='{$url}/{$module}/'>$module</a> > ";
if($l_a == 'index') {
$crumbs .= $controller;
} else {
$crumbs .= "<a href='{$url}/{$module}/{$controller}/'>$controller</a> > $action";
}
}

}
return $crumbs;
}

}

2 Step Views in Zend Framework with Zend_Layout Part 2

In the first part, we looked at the simple way to do 2 step views in Zend Framework prior to 1.5 using a front controller plugin. Now, with the release of 1.5, we have access to Zend_Layout, which is native support for implementing 2 step views.

First off, Visit Akra’s site, there is a lot of information of the Zend Framework there, and a great tutorial on Zend_Layout. You can find the article here, http://akrabat.com/2007/12/11/simple-zend_layout-example/, Also take a look at the official documentation here, http://framework.zend.com/manual/en/zend.layout.html

First off, I’ll assume you have a functioning bootstrap, and working application.

Inside your bootstrap you must start Zend_Layout’s MVC Helper. This can take a number of arguments in array fashion, the most important being the directory that you are going to store the templates in. I suggest views/layouts. See the official documentation for more options.


Zend_Layout::startMvc(array('layoutPath' => '../application/views/layouts'));

Now, before we go further, Here are some methods you can use in the controllers in your application.

(more…)

Zend Framework 1.5 Praise, and Free Skeleton App Download

If you know anything about me and my profession, you know that I am a extreme advocate of the Zend Framework and its standardization of PHP programming, well Zend has just release v1.5 of the framework.

To be honest, I could beat a dead horse by reiterating what is new in 1.5, however I am going to focus on what I have been working with and so far love about the new version.

Also, You can download my compiled skeleton 1.5 project, complete with the 1.5 Library at the end of this article. (more…)

BrokenWeb Security Consulting and Development in the works

I have mentioned a few times possibly starting a IT Security consulting and web development venture. Here lately, while working a full-time job, going to college full-time, taking care of my son, training MMA, and studying for the MYSQL-DEV exams, I don’t have time to put this together.

However in down time I have gone over ideas, talked to some people, and have some pretty neat things planned for this. I have a lot of great ideas for the site, including frequent blogs on security for both business owners and individuals wanting to become more secure. Video demonstrations of how attacks work. (more…)

2 Step Views in Zend Framework With SiteTemplate Part 1

I am a complete advocate of the Zend Framework, it is nothing but good. I will probably post sometime in the near future why I believe it is the best development option out there, but for now we are going to be talking about views.

Views coincide with the framework’s MVC architecture. The view is the presentation, or basically the templates that display the dynamic data manipulated by PHP.

For each Action you have in a controller, you have a view script, which is a phtml file. One solution to creating a uniform site, was on each phtml file, to include header and footers, like this:

<?php echo $this->render('header.phtml'); ?>
<h1><?php echo $this->title; ?></h1>
<?php echo $this->content; ?>
<?php echo $this->render('footer.phtml'); ?>

The problem with this is obvious, redundancy. In case you don’t know, programmers hate redundancy. Once you find yourself repeating code over and over again, in this case, rendering the header and footer, then it is time to create an automated solution. (more…)

LousVoice.com Launched!

In my last project I had the pleasure of working with a very experienced voice talent. His name is Lou Christian, and he has had almost 40 years in broadcast media. He does professional voice overs for radio and television. I created a web presence for him, as well as a back-end application for him to edit pages with a Rich Text Editor, with preview, as well as manage other functions of the site.

This was done on top of the Zend Framework 1.5, and the media player was created with Adobe Flex.

I have listened to his work, both dry and post production, and I was just blown away. The sound is very crisp, and is extremely good quality. His prices are also very reasonable, and to top it off, he is one class act. Lou is a really energetic and crazy guy who loves what he does.

So if you are looking for some voice over or voice tracking, please check out his web site at LousVoice.com