Elseif design tag?


(Luke Geoghegan) #1

Hello,

 

Does anyone know if its possible to use some kind of elseif statement on a Show If Design Area tag?

 

For example, I have the following code in my design which is showing content based on a users group:

 

<MySource_AREA id_name="quick_links" design_area="show_if">     <MySource_SET name="condition" value="in_user_group" />
        <MySource_THEN>%globals_asset_contents_raw:386838%</MySource_THEN>
        <MySource_ELSE>%globals_asset_contents_raw:363185%</MySource_ELSE>
</MySource_AREA>
 

What I want to do is add a statement so that if a user isn't a member of the first group but is in a second user group I will then show a different asset, ie:

 

IF user is in group x show x asset

ELSEIF user is in group y show y asset

ELSE show z asset

 

Can anyone help?

 

 


(Nic Hubbard) #2

Yes, this is possible through nesting of show_if tags and also using the print tag. 

 

<MySource_AREA id_name="in_group_2" design_area="show_if" print="no">
    <MySource_SET name="condition" value="in_user_group" />
        <MySource_THEN>In group 2</MySource_THEN>
        <MySource_ELSE>In none of the groups</MySource_ELSE>
</MySource_AREA>

<MySource_AREA id_name=“in_group_1” design_area=“show_if”>
    <MySource_SET name=“condition” value=“in_user_group” />
        <MySource_THEN>In user group 1!</MySource_THEN>
        <MySource_ELSE><MySource_print id_name=“in_group_2” /></MySource_ELSE>
</MySource_AREA>

You will then need to create a design customization and customize each of those design areas:

 

Screen%20Shot%202013-11-05%20at%209.52.5

 

Then choose the user group for each of the show_if areas:

 

Screen%20Shot%202013-11-05%20at%209.53.4

Screen%20Shot%202013-11-05%20at%209.53.5

 

Make sure to note that the in_group_2 show_if area uses print="no". This is needed.

 

I just tested this method and everything seems to work really well. Let me know how it works for you.


(Ryan Archer) #3

I've looked into this also but there is something that I cannot get to work. I want to show a different piece of nested content depending on what particular user group a user is in. I put in some nested content tags within the show_if tags but they are not showing up on the customisation.

 

Here is the code that I am using:

<MySource_AREA id_name="in_group_ikc" design_area="show_if" print="no">
    <MySource_SET name="condition" value="in_user_group" />
        <MySource_THEN><MySource_AREA id_name="ikc_content" design_area="nest_content" />This guy is in IKC</MySource_THEN>
        <MySource_ELSE>In none of the groups</MySource_ELSE>
</MySource_AREA>

<MySource_AREA id_name=“in_group_rlq” design_area=“show_if”>
<MySource_SET name=“condition” value=“in_user_group” />
<MySource_THEN><MySource_AREA id_name=“rlq_content” design_area=“nest_content” />This guy is in RLQ</MySource_THEN>
<MySource_ELSE><MySource_print id_name=“in_group_ikc” /></MySource_ELSE>
</MySource_AREA>

Is there any way to get this working? My purpose is to turn off/switch certain menus/sliders/elements depending on what user group is accessing the page.


(Ryan Archer) #4

My other issue is getting a third option into the show_if equation? How is that possible?

I am imagining it would be the same and then print the id_name but I don't think that works as that is really optimised for a boolean (either on or off).

 

If I get it to print two id_names that is not really going to work too well is it?


(Ryan Archer) #5

Ok, so I figured it out. Got stuck on a commuter train for 5 hours and I got really bored.

I haven't come across any type of OOP environment like SQUIZ before and effectively the ELSE IF statement doesn't even exist.

 

Basically have to set up a string of IF_ELSE statments and have triggers firing in the ELSE statemtent to suddenly show another IF ELSE statement (a bit like using JS statements to trigger another JS function instead of leaving it all centralized within one function call).

 

So to get what I wanted it looks like this:

 

<!-- Inserting nested content design area for use within IF_ELSE design area, turned off here and turned on within show_if statement if condition is met -->
<MySource_AREA id_name="ikc_panel" design_area="nest_content" print="no" />
<MySource_AREA id_name="rlq_panel" design_area="nest_content" print="no" />
<MySource_AREA id_name="ind_panel" design_area="nest_content" print="no" />
<MySource_AREA id_name="global_panel" design_area="nest_content" print="no" />
<!-- Inserting a header which changes it's style and content depending on the assigned user group (through use of a cookie -->
<MySource_AREA id_name="in_group_ind" design_area="show_if" print="no">
    <MySource_SET name="condition" value="in_user_group" />
        <MySource_THEN><MySource_print id_name="ind_panel" /></MySource_THEN>
        <MySource_ELSE><MySource_print id_name="global_panel" /></MySource_ELSE>
</MySource_AREA>

<MySource_AREA id_name=“in_group_ikc” design_area=“show_if” print=“no”>
    <MySource_SET name=“condition” value=“in_user_group” />
        <MySource_THEN><MySource_print id_name=“ikc_panel” /></MySource_THEN>
        <MySource_ELSE><MySource_print id_name=“in_group_ind” /></MySource_ELSE>
</MySource_AREA>

<MySource_AREA id_name=“in_group_rlq” design_area=“show_if”>
    <MySource_SET name=“condition” value=“in_user_group” />
        <MySource_THEN><MySource_print id_name=“rlq_panel” /></MySource_THEN>
        <MySource_ELSE><MySource_print id_name=“in_group_ikc” /></MySource_ELSE>
</MySource_AREA>

 

Just thought I would share it in case someone else gets a bit stuck.