Re: [fw-general] Zend Layout and _forward

2008-08-29 Thread pvechi

Tobias,

Thank you again. I tried the _forward but I only get the 'nav' on the view
and not the 'content'.  Same problem as before.  :(

My index controller has this:

class Customers_IndexController extends Zend_Controller_Action
{

function init()
{
$this-initView();
Zend_Loader::loadClass('Customers');
$this-view-baseUrl = $this-_request-getBaseUrl();
$this-view-user = Zend_Auth::getInstance()-getIdentity();
}

function preDispatch()
{
$auth = Zend_Auth::getInstance();
if (!$auth-hasIdentity()) {
$this-_redirect('auth/login');
}
}

function indexAction()
{
$this-view-title = Customers;
$customers = new Customers();
$this-view-customers = $customers-fetchAll();
$this-_forward('menu','navigation','default');
}

   // Other actions
}


Am i forwarding correctly?

++Tx
Pete


vladimirn wrote:
 
 Not so hard i think.
 If i understud well, you should use $this-_forward at the end of you
 action.
 So lets say you have IndexController.php and in this controller you want
 to use forward 
 ?php 
 
 class IndexController extends Zend_Controller_Action
 {
 public function indexAction()
   {
 //there is some stuff you want to do
 //and now you are calling your NavController
 $this-_forward('menu','nav'); // where 'menu' stand for menuAction in
 NavController and 'nav' is a NavController.php
 }
 }
 
 Also you will like to setup in scripts/view/nav/menu.phtml and put in this
 file whatever you want
 
 then in you layout.phtml just call ?=$this-layout()-nav ?
 
 i hope this will work or help :)
 
 
 
 
 pvechi wrote:
 
 Thanks for your reply Tobias.
 
 In my example where I send only the title to the nav variable, i do so
 for illustrative purposes. Eventually i want to send  a complete
 navigation menu.
 
 However, I am looking for direction with the code based on the example in
 the ZF documentation. I am unsure how to create the menu based on the
 layout view script, actionstack, or maybe the use of _forward, as it
 implies in the doucmentation.
 
 ++Tx
 
 Pete
 
 
 Tobias Schifftner wrote:
 
 Normally you should not always forward to an other action. Only if you
 really need to do so. Not all the time...
 
 Well, as I can see you use already ?= $this-layout()-content; ?, so
 all other $this-view variables will be within that. In your view script
 view/scripts/action.phtml you can just use
 
 ?= $this-title ?
 
 But this only works when you not forward all the time. Just stay in you
 indexAction() function and you can easily use your variables in
 view/scripts/index.phtml
 
 
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Zend-Layout-and-_forward-tp19178382p19219239.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Zend Layout and _forward

2008-08-28 Thread vladimirn

Not so hard i think.
If i understud well, you should use $this-_forward at the end of you
action.
So lets say you have IndexController.php and in this controller you want to
use forward 
?php 

class IndexController extends Zend_Controller_Action
{
public function indexAction()
{
//there is some stuff you want to do
//and now you are calling your NavController
$this-_forward('menu','nav'); // where 'menu' stand for menuAction in
NavController and 'nav' is a NavController.php
}
}

Also you will like to setup in scripts/view/nav/menu.phtml and put in this
file whatever you want

then in you layout.phtml just call ?=$this-layout()-nav ?

i hope this will work or help :)




pvechi wrote:
 
 Thanks for your reply Tobias.
 
 In my example where I send only the title to the nav variable, i do so for
 illustrative purposes. Eventually i want to send  a complete navigation
 menu.
 
 However, I am looking for direction with the code based on the example in
 the ZF documentation. I am unsure how to create the menu based on the
 layout view script, actionstack, or maybe the use of _forward, as it
 implies in the doucmentation.
 
 ++Tx
 
 Pete
 
 
 Tobias Schifftner wrote:
 
 Normally you should not always forward to an other action. Only if you
 really need to do so. Not all the time...
 
 Well, as I can see you use already ?= $this-layout()-content; ?, so
 all other $this-view variables will be within that. In your view script
 view/scripts/action.phtml you can just use
 
 ?= $this-title ?
 
 But this only works when you not forward all the time. Just stay in you
 indexAction() function and you can easily use your variables in
 view/scripts/index.phtml
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Zend-Layout-and-_forward-tp19178382p19207206.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Zend Layout and _forward

2008-08-28 Thread Tobias Schifftner

Hi Pete,

I actually did a start for a dynamic navigation. I never really finished
(and believe me, it's been a while) because I didn't really need it anymore
. But may be it gives you a hint.

Well, the navigation has to be on every page, why not use a plugin for
handeling?!?

class Navigation extends Zend_Controller_Plugin_Abstract
{
public function postDispatch (Zend_Controller_Request_Abstract $request)
{
 $this-view = Zend_Registry::get('Zend_View');

 $menuArray= $this-getAnArrayOfLinks();
 $this-getResponse()-insert('top_navigation',
$this-view-htmlList($menuArray));  

   }

   public function getAnArrayOfLink()
   {
  // Use database or whatever you like
   }
}


And in the view script just use ?= $this-layout()-navigation; ?

Just try your luck, don't know whether it really works that way. It's been
too long ;-)

Greetings,
Tobias
-- 
View this message in context: 
http://www.nabble.com/Zend-Layout-and-_forward-tp19178382p19209753.html
Sent from the Zend Framework mailing list archive at Nabble.com.



[fw-general] Zend Layout and _forward

2008-08-27 Thread pvechi

Hi there again,

I am creating the HTML in my application using Zend Layout using a similar
method shown in the Zend documentation.  Here is an extract from the
documentation:

As an example, let's say your code first hits FooController::indexAction(),
which renders some content to the default response segment, and then
forwards to NavController::menuAction(), which renders content to the 'nav'
response segment. Finally, you forward to CommentController::fetchAction()
and fetch some comments, but render those to the default response segment as
well (which appends content to that segment). Your view script could then
render each separately:

from this page:
http://framework.zend.com/manual/en/zend.layout.quickstart.html

I have this view script layout.phtml:

?php echo $this-partial('header.phtml'); ?

?php echo $this-escape($this-title); ?
?php echo $this-layout()-content; ?


?php echo $this-layout()-nav; ?

?php echo $this-partial('footer.phtml'); ?



In my CustomerController I have the following actions:


function indexAction()
{
$this-view-title = Customers;
$customers = new Customers();
$this-view-customers = $customers-fetchAll();
$this-render(null, 'content');
}

This supposedly sends everything to the variable 'content' in my layout
script (above).

I then have this postDispatch in the CustomerController that forwards to the
action to create the navigation menu:

function postDispatch()
{
$this-_forward('menu','navigation');
}

I have created a  NavigationController with a menuAction:

?php
class NavigationController extends Zend_Controller_Action
{
function init()
{
$this-initView();
$this-view-baseUrl = $this-_request-getBaseUrl();
}

function preDispatch()
{
$this-_helper-viewRenderer-setResponseSegment('nav');
}

function menuAction()
{
$this-view-menuTitle = 'Menu title goes here';
}


}

The problem that I am having is that the navigation menu is the only part
that appears on my screen.  The body 'content' which is suppose to show
customer information does not show.

Am I missusing _forward()?  I also looked into the actionstack method but I
have no idea how to implement this within the action controllers.  I looked
for examples too and I still don't get it.

Can anyone provide some direction?

++Tx
P


-- 
View this message in context: 
http://www.nabble.com/Zend-Layout-and-_forward-tp19178382p19178382.html
Sent from the Zend Framework mailing list archive at Nabble.com.


Re: [fw-general] Zend Layout and _forward

2008-08-27 Thread Tobias Schifftner

Normally you should not always forward to an other action. Only if you really
need to do so. Not all the time...

Well, as I can see you use already ?= $this-layout()-content; ?, so all
other $this-view variables will be within that. In your view script
view/scripts/action.phtml you can just use

?= $this-title ?

But this only works when you not forward all the time. Just stay in you
indexAction() function and you can easily use your variables in
view/scripts/index.phtml
-- 
View this message in context: 
http://www.nabble.com/Zend-Layout-and-_forward-tp19178382p19180230.html
Sent from the Zend Framework mailing list archive at Nabble.com.