Re: [Agavi-Users] users Digest, Vol 70, Issue 2

13 views
Skip to first unread message

Rafael Guerrero

unread,
Mar 18, 2013, 10:26:45 AM3/18/13
to us...@lists.agavi.org
I solved... for re-use template for al json response

case A )

in the config file output_tipe 
define ouput_tipe json -> layer


<layouts default="standard">
<layout name="standard">
        <layer name="content">
     <ae:parameter name="directory">%core.template_dir%</ae:parameter>
     <ae:parameter name="template">JsonResponse</ae:parameter>
</layer>
</layout>
</layouts>


Or Case B)

override setupHtml method

public function setupHtml(AgaviRequestDataHolder $rd, $layoutName = null){
    if($layoutName === null && $this->getContainer()->getParameter('is_slot', false)) {
        // it is a slot, so we do not load the default layout, but a different one
        // otherwise, we could end up with an infinite loop
        $layoutName = self::SLOT_LAYOUT_NAME;
    }

// now load the layout
// this method returns an array containing the parameters that were declared on the layout (not on a layer!) in output_types.xml
// you could use this, for instance, to automatically set a bunch of CSS or Javascript includes based on layout parameters -->
$this->loadLayout($layoutName);
    // if output type is json set the a unique template
    $outputType = $this->container->getOutputType()->getName();
    if (strtolower($outputType) == 'json'){
         $this->getLayer('content')->setParameter('directory', AgaviConfig::get('core.template_dir'));
 $this->getLayer('content')->setParameter('template', 'JsonResponse');
    }
}

On Sun, Mar 17, 2013 at 6:30 AM, <users-...@lists.agavi.org> wrote:
Send users mailing list submissions to
        us...@lists.agavi.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://lists.agavi.org/mailman/listinfo/users
or, via email, send a message with subject or body 'help' to
        users-...@lists.agavi.org

You can reach the person managing the list at
        users...@lists.agavi.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of users digest..."


Today's Topics:

   1. What are the available parameters for     AgaviTemplateLayer
      (Rafael Guerrero)
   2. Re: What are the available parameters for AgaviTemplateLayer
      (Peter Limbach)
   3. Re: What are the available parameters for AgaviTemplateLayer
      (Steffen Gransow)


----------------------------------------------------------------------

Message: 1
Date: Sat, 16 Mar 2013 19:50:07 -0430
From: Rafael Guerrero <tierr...@gmail.com>
Subject: [Agavi-Users] What are the available parameters for
        AgaviTemplateLayer
To: us...@lists.agavi.org
Message-ID:
        <CAA+=Sk8SFPjt=SC5uU+tLMppXqEju0o...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Hi Guys,


Where is the info about of valid paramteres for AgaviTemplateLayer ?
i want to set a custom template in custom directory for reuse template from
multiple modules
i saw the example into the web

// *re-use the input template* for presenting the errors in the form
$this->getLayer('content')->setTemplate('Input');


checking the class, i can see the magic metod __call

and the config files ( output_type ) i can see other property


<layer name="decorator">
        <ae:parameter name="*directory*">%core.template_dir%</ae:parameter>
        <ae:parameter name="*template*">Master</ae:parameter>
</layer>


i guess that i cant execute

$layer->setParameter('template', *$XXXX*);

or

$layer->setTemplate(*$XXX*);


why the  value for template parameter is a View Name?

can i set a filename ?

Are there other possible values  for the template parameter?

what other properties exist for the AgaviTemplateLayer ?


Thansk for your help


--
Atte
Rafael ?ngel Guerrero Godoy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.agavi.org/pipermail/users/attachments/20130316/f68a9959/attachment.html>

------------------------------

Message: 2
Date: Sun, 17 Mar 2013 10:10:24 +0100
From: Peter Limbach <peter....@gmail.com>
Subject: Re: [Agavi-Users] What are the available parameters for
        AgaviTemplateLayer
To: Agavi Users Mailing List <us...@lists.agavi.org>
Message-ID: <18AE3EAF-6A33-494F...@gmail.com>
Content-Type: text/plain; charset=iso-8859-1

the template parameter is not a view name it is the file name maybe this code snippet and the agavi faq could help you

http://mivesto.de/agavi/agavi-faq.html#general_18

https://gist.github.com/pelim/e401c563218b8b47c15a


Am 17.03.2013 um 01:20 schrieb Rafael Guerrero:

>
>
>
> Hi Guys,
>
>
> Where is the info about of valid paramteres for AgaviTemplateLayer ?
> i want to set a custom template in custom directory for reuse template from multiple modules
> i saw the example into the web
>
> // re-use the input template for presenting the errors in the form
> $this->getLayer('content')->setTemplate('Input');
>
> checking the class, i can see the magic metod __call
> and the config files ( output_type ) i can see other property
>
> <layer name="decorator">
>       <ae:parameter name="
> directory
> ">%core.template_dir%</ae:parameter>
>       <ae:parameter name="
> template
> ">Master</ae:parameter>
> </layer>
>
>
> i guess that i cant execute
> $layer->setParameter('template', $XXXX);
> or
> $layer->setTemplate($XXX);
>
> why the  value for template parameter is a View Name?
> can i set a filename ?
> Are there other possible values  for the template parameter?
> what other properties exist for the AgaviTemplateLayer ?
>
> Thansk for your help
>
> --
> Atte
> Rafael ?ngel Guerrero Godoy _______________________________________________
> users mailing list
> us...@lists.agavi.org
> http://lists.agavi.org/mailman/listinfo/users




------------------------------

Message: 3
Date: Sun, 17 Mar 2013 10:28:52 +0100
From: "Steffen Gransow" <gra...@mivesto.de>
Subject: Re: [Agavi-Users] What are the available parameters for
        AgaviTemplateLayer
To: "Agavi Users Mailing List" <us...@lists.agavi.org>
Message-ID: <op.wt23aeafeahkiq@graste-thinkpad>
Content-Type: text/plain; charset="utf-8"; Format="flowed";
        DelSp="yes"

Hi,

Agavi uses template lookup patterns to get the correct file to render as a
template. These lookup patterns can be set in output_types.xml or
dynamically.

Please have a look at
http://graste.github.com/Agavi-FAQ/agavi-faq.html#general_24 for a small
example.

By default agavi looks for localized templates (e.g. en/*.php or
*.en_UK.php). You can change the template lookup pattern defaults per
layer via the targets parameter.

This gives you a great deal of flexibility as you can do things like in
http://graste.github.com/Agavi-FAQ/agavi-faq.html#general_25 where you can
define a whole cascade of template lookups.

Kind regards,

Steffen

On Sun, 17 Mar 2013 01:20:07 +0100, Rafael Guerrero <tierr...@gmail.com>
wrote:

>
>
>
> Hi Guys,
>
>
> Where is the info about of valid paramteres for AgaviTemplateLayer ?
> i want to set a custom template in custom directory for reuse template
> from multiple modules
> i saw the example into the web
>
> // re-use the input template for presenting the errors in the form
> $this->getLayer('content')->setTemplate('Input');
>
>> checking the class, i can see the magic metod __call
> and the config files ( output_type ) i can see other property
>
>> <layer name="decorator">
>       <ae:parameter name="directory">%core.template_dir%</ae:parameter>
>       <ae:parameter name="template">Master</ae:parameter>
> </layer>
>
>> i guess that i cant execute
> $layer->setParameter('template', $XXXX);or
> $layer->setTemplate($XXX);
>
>> why the  value for template parameter is a View Name?
> can i set a filename ?
> Are there other possible values  for the template parameter?
> what other properties exist for the AgaviTemplateLayer ?
>
>> Thansk for your help
>>
>> --
> Atte
> Rafael ?ngel Guerrero Godoy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.agavi.org/pipermail/users/attachments/20130317/da0d50a4/attachment-0001.htm>

------------------------------

_______________________________________________
users mailing list
us...@lists.agavi.org
http://lists.agavi.org/mailman/listinfo/users


End of users Digest, Vol 70, Issue 2
************************************



--
Atte
Rafael Ángel Guerrero Godoy
Reply all
Reply to author
Forward
0 new messages