Quantcast

Setting a layout for a specific module

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Setting a layout for a specific module

Diego Potapczuk
I'm trying to specify a layout for a module but the old way is not working anymore, don´t know if something has changed.

Here is how I'm trying:

;;; View
resources.view.encoding = "utf-8"
resources.view.doctype = "XHTML1_TRANSITIONAL"
resources.view.contentType = "text/html;charset=utf-8"
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"
resources.layout.layout = "conteudos-digitais/layout"
resources.layout.viewSuffix = "php"
conteudoDigital.resources.layout.layout = "conteudos-digitais/layout"
espacoAberto.resources.layout.layout = "espaco-aberto/layout"



::: Diego Potapczuk
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Setting a layout for a specific module

scss
Hi,
I am not sure whether this is the reason or not(-I am doing this via a
plugin-) but you can try to define the layoutPath as well:
modulename.resources.layout.layoutPath = "views/layouts"

scs

On Thu, Apr 1, 2010 at 4:58 PM, Diego Potapczuk <[hidden email]> wrote:

> I'm trying to specify a layout for a module but the old way is not working
> anymore, don´t know if something has changed.
>
> Here is how I'm trying:
>
> ;;; View
> resources.view.encoding = "utf-8"
> resources.view.doctype = "XHTML1_TRANSITIONAL"
> resources.view.contentType = "text/html;charset=utf-8"
> resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"
> resources.layout.layout = "conteudos-digitais/layout"
> resources.layout.viewSuffix = "php"
> conteudoDigital.resources.layout.layout = "conteudos-digitais/layout"
> espacoAberto.resources.layout.layout = "espaco-aberto/layout"
>
>
>
> ::: Diego Potapczuk
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Setting a layout for a specific module

Diego Potapczuk
This is exactry whay I'm trying to do, but it is not working. (modulename.resources.layout.layoutPath = "views/layouts")

Fixed it another way.


::: Diego Potapczuk

»» Analista de sistemas
»» Tel: (71) 3287-8343 / (71) 9144-3062
»» http://www.diegoliveira.com.br


On Thu, Apr 1, 2010 at 11:07 AM, scs <[hidden email]> wrote:
Hi,
I am not sure whether this is the reason or not(-I am doing this via a
plugin-) but you can try to define the layoutPath as well:
modulename.resources.layout.layoutPath = "views/layouts"

scs

On Thu, Apr 1, 2010 at 4:58 PM, Diego Potapczuk <[hidden email]> wrote:
> I'm trying to specify a layout for a module but the old way is not working
> anymore, don´t know if something has changed.
>
> Here is how I'm trying:
>
> ;;; View
> resources.view.encoding = "utf-8"
> resources.view.doctype = "XHTML1_TRANSITIONAL"
> resources.view.contentType = "text/html;charset=utf-8"
> resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"
> resources.layout.layout = "conteudos-digitais/layout"
> resources.layout.viewSuffix = "php"
> conteudoDigital.resources.layout.layout = "conteudos-digitais/layout"
> espacoAberto.resources.layout.layout = "espaco-aberto/layout"
>
>
>
> ::: Diego Potapczuk
>

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Setting a layout for a specific module

scss
Check this:
http://blog.vandenbos.org/2009/07/19/zend-framework-module-specific-layout/
It says the path is module path relative. That might be the issue..

scs

On Thu, Apr 1, 2010 at 5:19 PM, Diego Potapczuk <[hidden email]> wrote:

> This is exactry whay I'm trying to do, but it is not working.
> (modulename.resources.layout.layoutPath = "views/layouts")
>
> Fixed it another way.
>
>
> ::: Diego Potapczuk
>
> »» Analista de sistemas
> »» Tel: (71) 3287-8343 / (71) 9144-3062
> »» http://www.diegoliveira.com.br
>
>
> On Thu, Apr 1, 2010 at 11:07 AM, scs <[hidden email]> wrote:
>>
>> Hi,
>> I am not sure whether this is the reason or not(-I am doing this via a
>> plugin-) but you can try to define the layoutPath as well:
>> modulename.resources.layout.layoutPath = "views/layouts"
>>
>> scs
>>
>> On Thu, Apr 1, 2010 at 4:58 PM, Diego Potapczuk <[hidden email]>
>> wrote:
>> > I'm trying to specify a layout for a module but the old way is not
>> > working
>> > anymore, don´t know if something has changed.
>> >
>> > Here is how I'm trying:
>> >
>> > ;;; View
>> > resources.view.encoding = "utf-8"
>> > resources.view.doctype = "XHTML1_TRANSITIONAL"
>> > resources.view.contentType = "text/html;charset=utf-8"
>> > resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"
>> > resources.layout.layout = "conteudos-digitais/layout"
>> > resources.layout.viewSuffix = "php"
>> > conteudoDigital.resources.layout.layout = "conteudos-digitais/layout"
>> > espacoAberto.resources.layout.layout = "espaco-aberto/layout"
>> >
>> >
>> >
>> > ::: Diego Potapczuk
>> >
>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Setting a layout for a specific module

Paul-3
In reply to this post by Diego Potapczuk
That is not going to work as the config is run during application
bootstrap, which is done before routing.

See Mathew's post for more info -
http://weierophinney.net/matthew/archives/234-Module-Bootstraps-in-Zend-Framework-Dos-and-Donts.html

On 4/1/2010 9:58 AM, Diego Potapczuk wrote:

> I'm trying to specify a layout for a module but the old way is not
> working anymore, don´t know if something has changed.
>
> Here is how I'm trying:
>
> ;;; View
> resources.view.encoding = "utf-8"
> resources.view.doctype = "XHTML1_TRANSITIONAL"
> resources.view.contentType = "text/html;charset=utf-8"
> resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"
> resources.layout.layout = "conteudos-digitais/layout"
> resources.layout.viewSuffix = "php"
> conteudoDigital.resources.layout.layout = "conteudos-digitais/layout"
> espacoAberto.resources.layout.layout = "espaco-aberto/layout"
>
>
>
> ::: Diego Potapczuk
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Setting a layout for a specific module

Graham Anderson
In reply to this post by Diego Potapczuk
On Thursday 01 April 2010 15:58:07 Diego Potapczuk wrote:
>I'm trying to specify a layout for a module but the old way is not working
>anymore, don´t know if something has changed.

The default layout plugin will accept a stack of paths in LIFO order. This
allows a very simple hack to always ensure that any module can have it's own
default layout which will automatically override the default module layout.

class App_Controller_Plugin_Layout extends Zend_Controller_Plugin_Layout
{

    public function __construct ($layout = null)
    {
        parent::__construct ($layout);
    }

    public function preDispatch(Zend_Controller_Request_Abstract $request)
    {
        // Insert current module layout dir to to overide any default layouts
        if ( $request->getModuleName() != 'default' ) {

            $layoutPath = APPLICATION_PATH . '/modules/' .
                          $request->getModuleName() . '/views/layouts';

            $paths = array();
            $paths[] = $this->getLayout()->getViewScriptPath();
            $paths[] = $layoutPath;

            $this->getLayout()->setViewScriptPath($paths);
        }
    }
}

Asssuming you set the following application config value:

    resources.layout.layout                  = "default"

Now any module with a default.phtml layout will override the default module
layout.

e.g APPLICATION_PATH/modules/foobar/views/layouts/default.phtml


Cheers the noo,
Graham

--
“What can be asserted without proof can be dismissed without proof.”
- Christopher Hitchens
Loading...