Share » Forums » Setup & design » Possible to override embedded object...

Possible to override embedded object template based on object's properties?

Possible to override embedded object template based on object's properties?

Thursday 17 February 2005 11:04:35 am - 4 replies

Modified on Thursday 17 February 2005 11:05:55 am by Joel Hardi

Author Message

Arran Price

Thursday 17 February 2005 11:22:50 am

Can you just override to a new template which has additional logic in it?
So instead of using an override to determine the display method, use the template itself to do the more complex checking.
ie

{section show=one set of rules}
   display stuff
{/section}
{section show=another set of rules}
   another set of display stuff
{/section}

Joel Hardi

Thursday 17 February 2005 11:40:25 am

Thanks, that's what I've wound up doing! Here's the final template if anyone's interested. It changes to inline mode for files, but for everything else uses the default 3.5 object.tpl code:

{* displays as inline or block-level based on the embedded object''s class *}
{switch match=$object.contentclass_id}
{case match='12'}{* 

files display as inline

*}
{set-block scope=root variable=is_block}false{/set-block}
{content_view_gui view=$view object_parameters=$object_parameters attribute_parameters=$object_parameters content_object=$object}
{/case}
{case}{* 

everything else display as block using standard eZ object.tpl

*}

{let object_align='right'}
    {switch match=$object_parameters.align}
        {case match='left'}
            {set object_align='left'}
        {/case}
        {case match='right'}
            {set object_align='right'}
        {/case}
        {case match='center'}
            {set object_align='center'}
        {/case}
        {case/}
    {/switch}

    <div class="object-{$object_align}{section show=ne($classification|trim,'')} {$classification|wash}{/section}">
        {content_view_gui view=$view object_parameters=$object_parameters attribute_parameters=$object_parameters content_object=$object}
    </div>

{/let}

{*
Set variable to true if the object should be rendered as a block
tag. If it should be rendered as inline use false.
{set-block scope=root variable=is_block}true{/set-block}

*}
{/case}
{/switch}

Craig Hirsch

Monday 28 March 2005 8:50:32 am

Wow, this solved an identical problem that I was having. Thanks for sharing your solution.

--
chirsch{AT}gmail{d.t}com

Jonathan Dillon-Hayes

Monday 28 March 2005 12:09:20 pm

I'd like to second thanks. This was very helpful on a project I'm hacking on with the nearly identical problem.

Jonathan

---------
FireBright provides advanced eZ deployment with root access
http://www.FireBright.com/

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu