Announcement

Collapse
No announcement yet.

Noob question about getting custom field codes and then using them in a conditional

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Noob question about getting custom field codes and then using them in a conditional

    Sorry if my methods are a mess, I'm terrible at programming.

    I'm trying to add a handful of custom field values as tooltips on attributes. It's going fine except I'm struggling to hide the tooltip if the specific custom field is blank.

    How I'm doing it now is I have custom fields like: 1_attr_tip, 2_attr_tip, 3_attr_tip, etc.

    ...and then on the attribute template I'm using the attribute index + '_attr_tip' to show the correct number tip for the matching attribute. Like this:
    <span class="tooltiptext"><mvt:item name="customfields" param="Read_Product_Code( g.Product_Code, l.settings:attribute:index $ '_attr_tip' )" />&mvt:customfields;</span>

    But now I wanna check if the custom field is null, and I have no idea how to use that read custom field function WITH the concatenation that I'm using to get the custom field's name . . . I have made my own dumb problem I tried to put it in a variable but I was having the same problem.

    tl;dr how do i use the attribute index + a string to get the custom field's code/contents and then use the contents in a conditional?

    Thanks!
    Last edited by teedle; 01-30-18, 03:35 PM. Reason: added tags

    #2
    You're gonna need to get a little bit deeper to make that work.

    First set a variable with the name of your dynamic variable:

    <mvt:assign name="l.variable" value="l.settings:attribute:index $ '_attr_tip'" />

    Then use the actual function to check the custom field:
    <mvt:do file="g.Module_Root $ '/modules/util/customfld.mvc'" name="l.success" value="Read_Product_Code(l.module, l.param, g.product_code, l.variable, l.settings:value)" /> l.settings:value / &mvt:value; should have your custom field value.
    M.A.D.* since 1997

    http://www.scotsscripts.com

    *miva application developers

    Comment


      #3
      Thank you for taking the time! So if I understand this right, I could use l.settings:value like I was planning? like
      <mvt:if expr="NOT ISNULL l.settings:value">
      <span class="tooltiptext"><mvt:item name="customfields" param="Read_Product_Code( g.Product_Code, l.settings:attribute:index $ '_attr_tip' )" />&mvt:customfields;</span>
      </mvt:if>

      Comment


        #4
        Yes and no, I don't think "g.Product_Code, l.settings:attribute:index $ '_attr_tip' " is going to work in the read_product_code item. The custom field value is now in the l.settings:value so if you want to display it, just use &mvt:value;
        M.A.D.* since 1997

        http://www.scotsscripts.com

        *miva application developers

        Comment

        Working...
        X