views:

431

answers:

3

We have taken on a site written in Zend framework, we didn't write the site and haven't use the Zend framework before so I'm interested in finding three things.

  1. How do I add new views to the site, adding in a new folder to the application/views/scripts directory seems to do nothing
  2. Are there any tutorials on how to add affiliate feeds and setups to a zend site that you can recomend?
  3. Are there any good tutorials on learning the framework, so far all I've found is vast amounts of material that confuses me

Thanks

+1  A: 

Are you adding the appropriate Zend_Controller as well? The Zend_Controller QuickStart is a good place to get started with MVC.

You might also look at Zend_Tool, which provides a script to help create the necessary structure.

cbeer
+1  A: 

Hi Teifion,

to answer your questions in order:

  1. You have to find the controller, that will emerge the view you want to add. There are two ways to get a view script rendered. The first one is a naming convention on the view script. The view has to be the same name as the action name of the controller. Like "indexAction" and index.phtml. The other way is to instanciate a view object within the controller and give a string with the view name at runtime. You may want to look at this excerpt:

    $view = new Zend_View(); $view->a = "Hay"; $view->b = "Bee"; $view->c = "Sea"; echo $view->render('someView.php');

which I took from http://framework.zend.com/manual/en/zend.view.controllers.html#zend.view.controllers.render

  1. I don't think that I understand what you mean by "affiliate feed"... are you talking about advertising or is it more like content syndication?

  2. The first thing you should read may be the Zend Framework Study Guide which you find here: http://www.zend.com/community/downloads. There are many tutorials an howtos out there but, this guide is made from Zend directly and should cover the main topics.

Regards, Mario

Mario Mueller
+1  A: 

Basically, views need corresponding controller actions. So the main index action (located, for example, in application/controllers/IndexController.php) would need a corresponding view at /application/views/scripts/index/index.phtml.

example: To reach an action within the Index Controller named fooAction() you would need a view file at /application/views/scripts/index/foo.phtml.

example: To reach the index action of contact controller you would need the controller at /application/controllers/ContactController.php (with an indexAction() inside it) and the view at /application/views/scripts/contact/index.phtml.

Getting beyond the absolute basics... view rendering can also be turned off or redirected but that is getting beyond the basics. Also if the app uses Zend_Layout there will be a layout file located somewhere like application/layouts/scripts/layout.phtml

Clear, concise and current ZF info can be strangely hard to come by. For tutorials check out:

  1. The ZF Quickstart
  2. Rob Allen's tutorial
  3. Some screencasts

For adding feeds I suppose you should check out the framework's documentation for Zend_Feed

gaoshan88