Skip to content

parse $thing in zem_contact_option #48

Open

Description

@trenc

Another little thingy, I've seen while testing: $thing (and/or label) in zem_contact_option should be parsed by parse().

Activity

  1. Bloke commented on Mar 9, 2017

    @Bloke
    Member

    Does it not get parsed here? I thought parse was recursive? Maybe it isn't...

    Do you have an example of a select/option form that breaks because it needs parsing? I can then use it to test the functionality and fix it if necessary.

  2. trenc commented on Mar 10, 2017

    @trenc
    Author

    Hm, weird thing. Here is my example:

    <txp:zem_contact_select break="" label="Category">
      <option value="">Choose&hellip;</option>                                                                                                
      <txp:category_list parent="a_category">              
        <txp:zem_contact_option value='<txp:category />'><txp:category title="1" /></txp:zem_contact_option>
      </txp:category_list>                                                          
    </txp:zem_contact_select>
    

    As in the code you mentioned it should be parsed. But only the wrapped zem_contact_option is parsed to

    <option class="zemOption" value="category_name">&lt;txp:category title=&quot;1&quot; /&gt;</option>
    

    The inner $thing is only handled by txpspecialchars() from the zem_contact_option tag. I've to explicitly parse the $thing in Line 1172 and L1173.

    Btw. How do you link to an line number here in GitHub markdown without linking to an issue (#L)?

  3. trenc commented on Mar 15, 2017

    @trenc
    Author

    I think, that's the problem. The txpspecialchars() in zem_contact_option is called first and all resulting $thing/$label - as <txp:category title="1" /> in my example - will be txpspecialchars()'d in the first. So there is only a &lt;txp:category title=&quot;1&quot; /&gt; to be parsed.

  4. Bloke commented on Mar 15, 2017

    @Bloke
    Member

    So is the solution to parse($thing) in zem_contact_option somewhere near the top of the function, before $atts is extracted so that the $match gets set correctly? e.g.:

    function zem_contact_option($atts, $thing = null)
    {
        static $options;
        static $match;
    
        if ($thing !== null) {
            $thing = parse($thing);
        }
    
        if ($atts === null) {
          ...
    

    Or will that introduce other oddness?

  5. trenc commented on Mar 17, 2017

    @trenc
    Author

    Not tested yet, but this will only parse $thing and not $label or $value, isn't it?
    The resulting html option inner text (option label) can be all other $atts parameters as $label and $value and $thing (see Line1173).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions