Share » Forums » Developer » conditional include in template language

conditional include in template language

conditional include in template language

Monday 09 February 2009 8:30:07 am - 3 replies

Modified on Monday 09 February 2009 8:30:48 am by Pascal Specht

Author Message

André R.

Monday 09 February 2009 10:37:38 am

Suggestion:
<custom name="is_member">
Content for member
</custom>

I have never tried to have a if in one template and the end of the if in the other, but I guess you get an error when you do it?

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Pascal Specht

Tuesday 10 February 2009 1:52:59 am

Hi André,

Thanks for your reply. Unfortunately, the <custom name="isMember">Content for member
</custom> suggestion does not work as expected: as soon as the content is for example a table with nested cells etc., when activating and deactivating the editor, I loose all the code between the XML markup (Content for member
). I'm under eZ Publish 3.9.3 and can't migrate this project. I'm now searching other ways to achieve it, but if you got other ideas they are greatly welcome!

Thanks in advance,
</Pascal>

Pascal Specht

Wednesday 11 February 2009 12:53:26 am

I didn't find a smart solution for this. But if anyone faces the same problem (having different content on the home page depending on the user belonging to a group or another) I ended up with this 'hack': I added code at the beginning of the frontpage template. This code checks if the rendered page is node 2 (home page) and if the user is belonging to a special group. If both conditions are met, it swaps the homepage node with another frontpage node (SpecialGroupHome). Not very nice, but works as intended.

</Pascal>

{if eq($node.node_id,2)}
{if userInSpecialGroup( ) }
{def $frontpages=fetch( content, list, hash( parent_node_id, 2,
                                               class_filter_type, include,
                                               class_filter_array, array('frontpage')
                                           ) )}
{foreach $frontpages as $fp}
{if eq($fp.name,'SpecialGroupHome')}
{set $node=$fp }
{/if}
{/foreach}
{/if}
{/if}

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

36 542 Users on board!

Forums menu