A
A
Ali Ali2020-01-02 23:24:22
Twig
Ali Ali, 2020-01-02 23:24:22

Block output via Twig?

Help Junior.
There is a modifier that displays categories in the opencart: link
I would like them to go in order 4 and then 4 pcs, at the moment they go 4 pcs then hot (Modifier
code:

<modification>
  <name>Подкатегории с картинками</name>
  <version>1.0</version>
  <code>Subcategory-Images</code>
  <author>opencart3x.ru</author>
  <link>https://opencart3x.ru</link>
  <file path="catalog/controller/product/category.php">
        <operation>
            <search index="0"><![CDATA[
$data['categories'][] = array(
            ]]></search>
            <add position="replace" offset="3"><![CDATA[
        if ($result['image']) {
          $image = $this->model_tool_image->resize($result['image'], 200, 150);
        } else {
          $image = $this->model_tool_image->resize('placeholder.png', 200, 150);
        }
        
        $data['categories'][] = array(
          'name'  => $result['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''),
          'href'  => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '_' . $result['category_id'] . $url),
          'thumb' => $image
        );
            ]]></add>
        </operation>
  </file>
  
  <file path="catalog/view/theme/*/template/product/category.twig">
        <operation>
            <search index="0"><![CDATA[
{% if categories %}
            ]]></search>
            <add position="replace"><![CDATA[
{% if categories %}
  <div class="col-sm-12">
    <div>
    <h3>{{ text_refine }}</h3>
    </div>
    <div style="text-align: center;">
    <div class="row">
    {% set i = 0 %}
    {% for category in categories %}
      <div class="col-sm-3 col-xs-6" style="margin-bottom: 20px;">
      <a href="{{ category.href }}"><img src="{{ category.thumb }}" alt="{{ category.name }}" /></a>
      <a href="{{ category.href }}">{{ category.name }}</a>
      </div>
      {% set i = i+1 %}
      {% if i == 4 %}
      <div class="clearfix"></div>
      {% endif %}
    {% endfor %}
    </div>
    </div>
  </div>
{% endif %}
{% if 2+2==5 %}
            ]]></add>
        </operation>
  </file>
  
</modification>

help me please

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question