I'm working with magento 2.

I can use ifconfig attribute in the block code, and it works well.

<block class="Magento\Catalog\Block\Category\View" name="category_desc_main_column" template="category/desc_main_column.phtml" ifconfig="config_path/group/field" before="category.products"/>

But I tried to use it for move, it didn't work.

<move element="category.image" destination="content" ifconfig="config_path/group/field" before="-"/>

Anyone know how to use it for moving?

  • Have you looked for it? I see it in the block reader, but nothing in the move one. Don't think you can. – nevvermind Oct 4 '15 at 20:36
  • Is there any other way for it without using ifconfig? – Mike Oct 5 '15 at 0:44

From what i understand you can't use ifconfig on move. In the class Magento\Framework\View\Layout\Reader\Block.php there is a check for the attribute ifconfig:

$configPath = (string)$currentElement->getAttribute('ifconfig');


However on the move block is doesn't actually check for the ifconfig attribute:

protected function scheduleMove(Layout\ScheduledStructure $scheduledStructure, Layout\Element $currentElement)
        $elementName = (string)$currentElement->getAttribute('element');
        $destination = (string)$currentElement->getAttribute('destination');
        $alias = (string)$currentElement->getAttribute('as') ?: '';
        if ($elementName && $destination) {
            list($siblingName, $isAfter) = $this->beforeAfterToSibling($currentElement);
                [$destination, $siblingName, $isAfter, $alias]
        } else {
            throw new \Magento\Framework\Exception\LocalizedException(
                new \Magento\Framework\Phrase('Element name and destination must be specified.')
        return $this;


In Theroy you shouldn't need the ifconfig on the move if there is already an ifconfig on the block as the block won't be rendered and thus not moved.

Hope that makes sense.

  • Is there any extension with strong feature of ifconfig like 1.x? – Mike May 20 '16 at 16:00
  • Hey @Dmitry i don't think there is or one that i'm not aware of. What do you need the ifconfig for? – rob3000 May 23 '16 at 0:27
  • eg: <action method="setTemplate" ifconfig="config_path/group/field" condition="one_column"><template>page/1column.phtml</template></action> I meant "ifconfig" and "condition" – Mike May 23 '16 at 3:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.