Jump to content

Add condition to theme hook


DreamOn

Recommended Posts

Hi,

Is there a way to add a condition in theme hook?

This doesn't work:

array (
      'selector' => 'li.ipsDataItem.ipsDataItem_responsivePhoto',
      'type' => 'add_attribute',
      'attributes_add' => 
      array (
        0 => 
        array (
          'key' => 'data-pinned',
          'value' => '{{if $row->mapped(\'pinned\') === 1}}pinned{{endif}}',
        ),
      ),
    ),

ParseError: syntax error, unexpected '&' (0)

Thanks.

Link to comment
Share on other sites

No, on attributes you cannot add conditional checks like IF. I've asked for this kind of support to be added a few times (as well as other developers too). So far nothing has been done about it, maybe in 4.3... but I doubt it's being added in there either :p

You could try working around it with some tricks/hacks, but it depends on what you want to do and where exactly.

Link to comment
Share on other sites

On 28/12/2017 at 7:35 PM, teraßyte said:

No, on attributes you cannot add conditional checks like IF. I've asked for this kind of support to be added a few times (as well as other developers too). So far nothing has been done about it, maybe in 4.3... but I doubt it's being added in there either :p

You could try working around it with some tricks/hacks, but it depends on what you want to do and where exactly.

Thanks @teraßyte.

I would like to add a html container, from :

<div class="test">...</div>

to :

<div class="container">
	<div class="test">...</div>
</div>

Do you have an idea how I can do this?

Thanks.

Link to comment
Share on other sites

5 hours ago, DreamOn said:

Thanks @teraßyte.

I would like to add a html container, from :


<div class="test">...</div>

to :


<div class="container">
	<div class="test">...</div>
</div>

Do you have an idea how I can do this?

Thanks.

That being the case you cannot use the attribute to add a container. Try instead what I mentioned in your other topic about exporting the hook manually and then modifying it to add only the opening/closing HTML tags separately.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...