Posts tagged: view

Zend Framework: Render If Exists

By , Sunday 12th December 2010 4:19 pm

Summary

This is a quick post to discuss the rather simple view helper I created for rendering a Zend Framework style view file only if it exists. Generally asking the code to render a file which doesn’t exist will throw an exception. Therefore I created a wrapper for the Zend_View::render() method which determined whether the file exists and if so renders, otherwise simply returns an empty string.
Continue reading 'Zend Framework: Render If Exists'»

Zend Framework Body Tag View Helper

By , Saturday 21st August 2010 11:13 pm
Photo from  http://www.flickr.com/photos/daniello/

Photo from http://www.flickr.com/photos/daniello/

Summary

Here I discuss the creation of a view helper for modifying HTML tags, and more specifically body tags. The created view helper allows functionality similar to the head*/inlineScript view helpers already in the standard Zend Framework view helpers, but allows the programmatic modification of tag attributes. Definitely check out the demo page and the code on github.

Motivation

The standard Zend Framework view helpers are a great set of tools for streamlining mundane view tasks and allowing for the modification/addition of scripts and header blocks (generally held in the layout) from within the view without applying ugly hacks (i.e. the head*/inlineScript view helpers).

Upon occasion I have found need to make modifications to the <body> tag, for example adding an onload, class, or style attribute etc. I also required to be able to perform this from within other view helpers. Take this following contrived example…

On website X, certain pages include standard dojo forms. These dojo forms are held within view helpers for convenience. Generally it has been decided not to include the dojo CSS classes in the body tag and only add them when necessary. There maybe several view helpers on the page that need to add their own attributes to the body tag. (I said it was contrived)

The code is available in my GIT repository @ github and the demo page.
Continue reading 'Zend Framework Body Tag View Helper'»

Creating URL in Zend Custom View Helper

By , Thursday 28th January 2010 11:01 pm

This may seem simple, but I was banging my head trying to create a URL in a custom view helper in Zend Framework. I have routing setup which gets the module from the sub-domain in use so I couldn’t use a simple hardcoded URL.

Continue reading 'Creating URL in Zend Custom View Helper'»

Dynamically add pages to Zend_Navigation container at runtime

By , Thursday 7th January 2010 10:50 pm

In a continuation on my last post about Zend_Navigation, Route requests for sitemap.xml to custom controller/action, this post is about dymnamically adding pages to a Zend_Navigation container at runtime/script execution.

Its all well and good specifying your pages in a ini or xml file but at some point you’re going to have changing pages in your site that you want as part of a menu, sitemap, or to be included in your breadcrumb trail. Therefore what we need to do is add pages to our Zend_Navigation container at runtime. Examples for this would be in adding news items, blog posts, or page comments, etc.

Continue reading 'Dynamically add pages to Zend_Navigation container at runtime'»

Panorama Theme by Themocracy

1 visitors online now
0 guests, 1 bots, 0 members
Max visitors today: 6 at 12:00 am UTC
This month: 31 at 09-06-2017 03:33 pm UTC
This year: 45 at 02-01-2017 10:28 pm UTC
All time: 130 at 28-03-2011 10:40 pm UTC