1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.3 (Solved) Desperate Xen Syntax Help Needed

Discussion in 'XenForo Questions and Support' started by HeadHodge, May 17, 2014.

  1. HeadHodge

    HeadHodge Active Member

    Hi Everyone,

    I'm new to xen coding and need some desperate help for a project I'm working on.
    I've got what I want it to do 90% figured out. But I JUST CAN'T figure out the last part.

    For a new forum I created in the Node Tree in the AdminCP, I added the following to the Header Template Html (from the AdminCP):

    {xen:raw $thread.customFields.1.fields.ReviewForm_Effect.field_value}
    <br />

    {xen:raw $thread.customFields.1.fields.ReviewForm_Effect.fieldChoices.Noticeable_Effect}
    <br /><br />

    They both work fine.
    The field_value displays in the header as "Noticeable_Effect"
    The Noticeable_Effect displays in the header as "Warning: Product has Very Noticeable Effects!"

    But for the life of me, I simply can't figure out how to do:
    {xen:raw $thread.customFields.1.fields.ReviewForm_Effect.fieldChoices[{$thread.customFields.1.fields.ReviewForm_Effect.field_value}}]}

    No matter how many ways I try, when I try to save my change with this in it, I get a "SYNTAX ERROR" and I'm not able save the Header Template, let alone get it to work.

  2. Liam W

    Liam W Well-Known Member

    What are you trying to do with that? It almost looks like you're trying to use array notation... Array are accessed with a period. If you want to use a value as a key, use a period and then use curly braces with the variable:

    {xen:raw $thread.customFields.1.fields.ReviewForm_Effect.fieldChoices.{$thread.customFields.1.fields.ReviewForm_Effect.field_value}}
    If you want them to appear side-by-side, you have to enter them separately...

    So, what exactly are you trying to do?
  3. HeadHodge

    HeadHodge Active Member

    OMG Thanks for a reply.

    These are variables from "Custom Fields add-on". I have a form that contains a radio button with three choices. The fieldChoice above is the array that contains the value of each choice (i.e. "Has No Effects", "Has Moderate Effects", "Has Extreme Effects"). The user picks the appropriate one on the radio button and the array id that the user selected is contained in the field "field_value" which in this case is the value "Noticeable_Effect". So I'm basically trying to access one element in an array to display their choice of "Warning: Product has Very Noticeable Effects!"
  4. HeadHodge

    HeadHodge Active Member

    P.S. Just tried the snippet you provided and still get "SYNTAX ERROR"
  5. HeadHodge

    HeadHodge Active Member

    Wew!!!..... Finally found the magic sequence:


    I don't know where I was going wrong. Trying to use the [] instead of the .{}

    So thanks for the snippet, that actually gave the idea to try it that way.

    p.s. Wish I could find better documentation on how to do this. I have literally combed this site for two days straight, trying to find something, and was beginning to freak....

Share This Page