View Partial from another action

5 messages Options
Embed this post
Permalink
marko.korhonen

View Partial from another action

Reply Threaded More More options
Print post
Permalink
I wanted to render some part of the page from some other action: {module/controller/action/params}.

So I made following in my action:

$link = 'http://ww.mydomain.com/module/controller/action/param1/value';

$client = new Zend_Http_Client($link);
$response = $client->request();

// Initial content for my Ajax-driven partial in this view
$this->view->partial_content_to_my_page = $response->getBody();

I use that link as a Ajax source but I wanted to render initial view without Ajax. Only when this partial
is updated by some user action, I will update it via Ajax.


So my question is:

Is this Zend_Http_Client usage in this case ok? What are the pros and cons in this approach?
Does it take too much resources or something? Is it safe?
Or can I do it some other way? Should I make some action helper which runs selected action and
returns its rendered view to me?



br, Marko
Jack Sleight

Re: View Partial from another action

Reply Threaded More More options
Print post
Permalink
Unfortunately the wiki is down right now, but when it's back up check
out the Zend_View Enhanced proposal. It provides built in support for
partials, and you can call them simply with
$this->partial('controller/action');. There is a sample implementation
with the proposal, which I've been using for a while now with no
problems. In the meantime do a search on the mailing list for partials,
this has come up a number of times and there are a few solutions
floating about. The Http_Client method is completely unnecessary, and
yes, I would imagine there would be a major impact on performance
(though that is just my assumption).

Marko Korhonen wrote:

> I wanted to render some part of the page from some other action:
> {module/controller/action/params}.
>
> So I made following in my action:
>
> $link = 'http://ww.mydomain.com/module/controller/action/param1/value';
>
> $client = new Zend_Http_Client($link);
> $response = $client->request();
>
> // Initial content for my Ajax-driven partial in this view
> $this->view->partial_content_to_my_page = $response->getBody();
>
> I use that link as a Ajax source but I wanted to render initial view without
> Ajax. Only when this partial
> is updated by some user action, I will update it via Ajax.
>
>
> So my question is:
>
> Is this Zend_Http_Client usage in this case ok? What are the pros and cons
> in this approach?
> Does it take too much resources or something? Is it safe?
> Or can I do it some other way? Should I make some action helper which runs
> selected action and
> returns its rendered view to me?
>
>
>
> br, Marko
>  

--
Jack
marko.korhonen

Re: View Partial from another action

Reply Threaded More More options
Print post
Permalink
Thanks,

I downloaded View helper named "controller" from Zend_View Enhanced SVN and
now I can do my rendering with following easy call:

echo $this->controller('action', 'controller', 'module', array('param1' => 'value'));

Cool!

Thanks again Jack!

br, Marko


Jack Sleight wrote:
Unfortunately the wiki is down right now, but when it's back up check
out the Zend_View Enhanced proposal. It provides built in support for
partials, and you can call them simply with
$this->partial('controller/action');. There is a sample implementation
with the proposal, which I've been using for a while now with no
problems. In the meantime do a search on the mailing list for partials,
this has come up a number of times and there are a few solutions
floating about. The Http_Client method is completely unnecessary, and
yes, I would imagine there would be a major impact on performance
(though that is just my assumption).

Marko Korhonen wrote:
> I wanted to render some part of the page from some other action:
> {module/controller/action/params}.
>
> So I made following in my action:
>
> $link = 'http://ww.mydomain.com/module/controller/action/param1/value';
>
> $client = new Zend_Http_Client($link);
> $response = $client->request();
>
> // Initial content for my Ajax-driven partial in this view
> $this->view->partial_content_to_my_page = $response->getBody();
>
> I use that link as a Ajax source but I wanted to render initial view without
> Ajax. Only when this partial
> is updated by some user action, I will update it via Ajax.
>
>
> So my question is:
>
> Is this Zend_Http_Client usage in this case ok? What are the pros and cons
> in this approach?
> Does it take too much resources or something? Is it safe?
> Or can I do it some other way? Should I make some action helper which runs
> selected action and
> returns its rendered view to me?
>
>
>
> br, Marko
>  

--
Jack
Jörg Sandkuhle

Re: View Partial from another action

Reply Threaded More More options
Print post
Permalink
Hi,

i tried "echo $this->partial('user/show.phtml');" within a template.
That works fine so far - the show.phtml is rendered in my master
layout.phtml file.

But when i use "echo
$this->controller('show','user','default',array('param1'=>'value'));"
only the show.phtml file is rendered, the layout.phtml not.

Did i missed something?

Thanks, Jörg

Marko Korhonen schrieb:

> Thanks,
>
> I downloaded View helper named "controller" from Zend_View Enhanced SVN and
> now I can do my rendering with following easy call:
>
> echo $this->controller('action', 'controller', 'module', array('param1' =>
> 'value'));
>
> Cool!
>
> Thanks again Jack!
>
> br, Marko
>
>
>
> Jack Sleight wrote:
>  
>> Unfortunately the wiki is down right now, but when it's back up check
>> out the Zend_View Enhanced proposal. It provides built in support for
>> partials, and you can call them simply with
>> $this->partial('controller/action');. There is a sample implementation
>> with the proposal, which I've been using for a while now with no
>> problems. In the meantime do a search on the mailing list for partials,
>> this has come up a number of times and there are a few solutions
>> floating about. The Http_Client method is completely unnecessary, and
>> yes, I would imagine there would be a major impact on performance
>> (though that is just my assumption).
>>
>> Marko Korhonen wrote:
>>    
>>> I wanted to render some part of the page from some other action:
>>> {module/controller/action/params}.
>>>
>>> So I made following in my action:
>>>
>>> $link = 'http://ww.mydomain.com/module/controller/action/param1/value';
>>>
>>> $client = new Zend_Http_Client($link);
>>> $response = $client->request();
>>>
>>> // Initial content for my Ajax-driven partial in this view
>>> $this->view->partial_content_to_my_page = $response->getBody();
>>>
>>> I use that link as a Ajax source but I wanted to render initial view
>>> without
>>> Ajax. Only when this partial
>>> is updated by some user action, I will update it via Ajax.
>>>
>>>
>>> So my question is:
>>>
>>> Is this Zend_Http_Client usage in this case ok? What are the pros and
>>> cons
>>> in this approach?
>>> Does it take too much resources or something? Is it safe?
>>> Or can I do it some other way? Should I make some action helper which
>>> runs
>>> selected action and
>>> returns its rendered view to me?
>>>
>>>
>>>
>>> br, Marko
>>>  
>>>      
>> --
>> Jack
>>
>>
>>    
>
>  

 

Pádraic Brady

Re: View Partial from another action

Reply Threaded More More options
Print post
Permalink
In reply to this post by marko.korhonen
Some javascript/style in this post has been disabled (why?)
Hi Jörg,

The ZVE proposal contains example implementation code to demonstrate some basic functionality - this means some of the code is not fully functional. A lot of it is in simpler use cases, with some minor tweaking, as evidenced by it's use in a few projects already - patchy code is better than no code ;). Once ZVE and Zend_Layout are accepted into the incubator we'll be able to work on implementing the proposal in full.

Until then, I am not working on the ZVE code until I have incubator access. It's been a long time since I started the proposal so a few weeks more isn't going to make much difference to those of us already using the current incarnation. Plus I have a ton of other projects to stay on top of ;).

Best regards
Paddy
 
Pádraic Brady

http://blog.astrumfutura.com
http://www.patternsforphp.com
OpenID Europe Foundation Member-Subscriber


----- Original Message ----
From: Jörg Sandkuhle <[hidden email]>
To: [hidden email]
Sent: Thursday, September 27, 2007 10:19:08 PM
Subject: Re: [fw-mvc] View Partial from another action

Hi,

i tried "echo $this->partial('user/show.phtml');" within a template.
That works fine so far - the show.phtml is rendered in my master
layout.phtml file.

But when i use "echo
$this->controller('show','user','default',array('param1'=>'value'));"
only the show.phtml file is rendered, the layout.phtml not.

Did i missed something?

Thanks, Jörg

Marko Korhonen schrieb:

> Thanks,
>
> I downloaded View helper named "controller" from Zend_View Enhanced SVN and
> now I can do my rendering with following easy call:
>
> echo $this->controller('action', 'controller', 'module', array('param1' =>
> 'value'));
>
> Cool!
>
> Thanks again Jack!
>
> br, Marko
>
>
>
> Jack Sleight wrote:
>  
>> Unfortunately the wiki is down right now, but when it's back up check
>> out the Zend_View Enhanced proposal. It provides built in support for
>> partials, and you can call them simply with
>> $this->partial('controller/action');. There is a sample implementation
>> with the proposal, which I've been using for a while now with no
>> problems. In the meantime do a search on the mailing list for partials,
>> this has come up a number of times and there are a few solutions
>> floating about. The Http_Client method is completely unnecessary, and
>> yes, I would imagine there would be a major impact on performance
>> (though that is just my assumption).
>>
>> Marko Korhonen wrote:
>>    
>>> I wanted to render some part of the page from some other action:
>>> {module/controller/action/params}.
>>>
>>> So I made following in my action:
>>>
>>> $link = 'http://ww.mydomain.com/module/controller/action/param1/value';
>>>
>>> $client = new Zend_Http_Client($link);
>>> $response = $client->request();
>>>
>>> // Initial content for my Ajax-driven partial in this view
>>> $this->view->partial_content_to_my_page = $response->getBody();
>>>
>>> I use that link as a Ajax source but I wanted to render initial view
>>> without
>>> Ajax. Only when this partial
>>> is updated by some user action, I will update it via Ajax.
>>>
>>>
>>> So my question is:
>>>
>>> Is this Zend_Http_Client usage in this case ok? What are the pros and
>>> cons
>>> in this approach?
>>> Does it take too much resources or something? Is it safe?
>>> Or can I do it some other way? Should I make some action helper which
>>> runs
>>> selected action and
>>> returns its rendered view to me?
>>>
>>>
>>>
>>> br, Marko
>>>  
>>>      
>> --
>> Jack
>>
>>
>>    
>
>  






Looking for a deal? Find great prices on flights and hotels with Yahoo! FareChase.