All pastes #338997 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-02-03 20:10 UTC
rendered paste body
Okay....
I have a DD object, (Admin Controls), which will hold a several properties.
These properties will each relate to a specific thing which I may wish to show/hide within various Admin-Create/Admin-Modify Pages.

EXAMPLE:
  I may create a set of DD proeprties to control whether someone editing a Xarpage can see a DD field for adding a Sub-Title to the page.
   If the Admin Control is set to YES, then the person editing the page will beable to see the feild.
   If the Admin Control is set to NO, then the person will not see that field.

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

The Admin Control DD object will have to be referenced...


<xar:set name="testing">#xarModAPIFunc('dynamicdata','user','getitems',array('modid' => 182, 'itemtype' => 3,'itemid' => 14))#</xar:set>

<xar:set name="testing">current($testing)</xar:set>

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

Then each property would have to be checked against...


<xar:set name="value1">#$testing['dd-property-name']#</xar:set>
<xar:if condition="!empty($value1) and $value1 eq 'on'">
its ON
<xar:elseif condition="!empty($value1) and $value1 eq 'off'" />
its OFF
<xar:elseif condition="empty($value1)" />
Its Empty ?
<xar:else />
</xar:if>

(OKAY... all the Elseif stuff is a little OTT, but I need to see what is happening... if anything :) )


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


This should be done within the relevant admin-modify-objectname.xt   file for Dynamic data.
In this scenario, the "admin-modify" I'm refering to is a xarpage... in DD this is called xarpages_6...
... admin-modify-xarpages_6.xt

In this file I need to do conditional checks to find and seperate the DD properties that I will want to control the visibility of.



<xar:foreach in="$properties" key="$name">

	<xar:if condition="$name eq 'dd-property-1'">
            <<DO SOMETHING HERE>>
        <xar:else />
            <div class="xar-form-input-wrapper">
                  <xar:data-label property="$properties[$name]" label="id" />
                  <xar:data-input property="$properties[$name]" />
            </div>
        </xar:if>
</xar:foreach>



Where it says  "<<DO SOMETHING HERE>>   Should be where I do my conditional checks to see what the Admin Control says...



<xar:foreach in="$properties" key="$name">

   <xar:if condition="$name eq 'dd-property-1'">

      <xar:set name="testing">#xarModAPIFunc('dynamicdata','user','getitems',array('modid' => 182, 'itemtype' => 3,'itemid' => 14))#</xar:set>
      <xar:set name="testing">current($testing)</xar:set>

      <xar:set name="value1">#$testing['dd-property-name']#</xar:set>
         <xar:if condition="!empty($value1) and $value1 eq 'on'">
            IT'S ON - SO SHOW...

            <div class="xar-form-input-wrapper">
                  <xar:data-label property="$properties[$name]" label="id" />
                  <xar:data-input property="$properties[$name]" />
            </div>

         <xar:elseif condition="!empty($value1) and $value1 eq 'off'" />
            IT'S OFF - SO SHOW NOTHING!
         <xar:elseif condition="empty($value1)" />
            IT'S EMPTY (STUFFED UP PASSING THE VALUE!)
         <xar:else />
            SOMETHING ELSE HAS HAPPEND !
         </xar:if>


        <xar:else />


            <div class="xar-form-input-wrapper">
                  <xar:data-label property="$properties[$name]" label="id" />
                  <xar:data-input property="$properties[$name]" />
            </div>


        </xar:if>

</xar:foreach>


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

I believe the above to be correct.
Though I few I have ommited something, or have a fault in my application of the logic, (or the logic itself :) ),
for simply using the the text for IT'S ON / IT'S OFF... I get the expected results.
As soon as I add the actualy Label and Input tags.... it shows up no matter what, whether it is switched on or off!
>>??<<