自定义Shopify中的Default_pagination编号样式

发布于 2025-02-01 04:41:18 字数 1029 浏览 2 评论 0 原文

我正在尝试自定义Default_Pagination过滤器的数字。我需要在数字上显示一个盒子。因此,为此,我需要为数字创建一个自定义类,并更改CSS中的样式。但是我不知道该怎么做。一点点帮助将不胜感激。

这是我的代码:

<div class="container">
    {% paginate collection.products by 5 %}
        {% for product in collection.products %}
            <a href="{{ product.url }}"><img src="{{ product.featured_image | img_url: 'medium' }}" alt="{{ product.title }}">
                <figcaption>{{ product.title }} 
                    {% if product.compare_at_price_max > 0 %}
                        <span>{{ product.compare_at_price_max | money }}</span>
                        <span>{{ product.price | money }}</span>
                    {% else %} 
                        <span>{{ product.price | money }}</span>
                    {% endif %}
                </figcaption>
            </a>
        {% endfor %}
    {{ paginate | default_pagination: next: '>', previous: '<' }}   
   {% endpaginate %}
</div>

I am trying to customize the numbers for the default_pagination filter. I need to show a box around the numbers. So for this, I need to create a custom class for the numbers, and change the style in CSS. But I can't figure out how to do it. A bit of help will be much appreciated.

This is my code:

<div class="container">
    {% paginate collection.products by 5 %}
        {% for product in collection.products %}
            <a href="{{ product.url }}"><img src="{{ product.featured_image | img_url: 'medium' }}" alt="{{ product.title }}">
                <figcaption>{{ product.title }} 
                    {% if product.compare_at_price_max > 0 %}
                        <span>{{ product.compare_at_price_max | money }}</span>
                        <span>{{ product.price | money }}</span>
                    {% else %} 
                        <span>{{ product.price | money }}</span>
                    {% endif %}
                </figcaption>
            </a>
        {% endfor %}
    {{ paginate | default_pagination: next: '>', previous: '<' }}   
   {% endpaginate %}
</div>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

睡美人的小仙女 2025-02-08 04:41:18

而不是使用Shopify Liquid default_pagination

<nav class="Pagination">
  <ul class="Pagination__List">
    {%- if paginate.previous -%}
      <li>
        <a
          class="Pagination__Item Pagination__Item--Next" 
          href="{{ paginate.previous.url }}"
          >
          Next Page
        </a>
      </li>
    {%- endif -%}

    {%- for part in paginate.parts -%}
      <li>
        {%- if part.is_link -%}
          <a
            class="Pagination__Item"
            href="{{ part.url }}"
            >
            {{ part.title }}
          </a>
        {%- else -%}
          {%- if part.title == paginate.current_page -%}
            <span class="Pagination__Item Pagination__Item--Current">{{ part.title }}</span>
          {%- else -%}
            <span class="Pagination__Item">{{ part.title }}</span>
          {%- endif -%}
        {%- endif -%}
      </li>
    {%- endfor -%}

    {%- if paginate.next -%}
      <li>
        <a
          class="Pagination__Item Pagination__Item--Prev"
          href="{{ paginate.next.url }}"
          >
          Previous Page
        </a>
      </li>
    {%- endif -%}
  </ul>
</nav>

查看液体分页对象有关更多信息。

然后,按照您想要的方式进行造型应该很容易。如果您需要帮助,请发表评论。我很高兴提供帮助:)

Instead of using Shopify Liquid's default_pagination filter which creates a boilerplate pagination component for you, you can create a fully customizable pagination like this:

<nav class="Pagination">
  <ul class="Pagination__List">
    {%- if paginate.previous -%}
      <li>
        <a
          class="Pagination__Item Pagination__Item--Next" 
          href="{{ paginate.previous.url }}"
          >
          Next Page
        </a>
      </li>
    {%- endif -%}

    {%- for part in paginate.parts -%}
      <li>
        {%- if part.is_link -%}
          <a
            class="Pagination__Item"
            href="{{ part.url }}"
            >
            {{ part.title }}
          </a>
        {%- else -%}
          {%- if part.title == paginate.current_page -%}
            <span class="Pagination__Item Pagination__Item--Current">{{ part.title }}</span>
          {%- else -%}
            <span class="Pagination__Item">{{ part.title }}</span>
          {%- endif -%}
        {%- endif -%}
      </li>
    {%- endfor -%}

    {%- if paginate.next -%}
      <li>
        <a
          class="Pagination__Item Pagination__Item--Prev"
          href="{{ paginate.next.url }}"
          >
          Previous Page
        </a>
      </li>
    {%- endif -%}
  </ul>
</nav>

Check out the Liquid paginate object for more information.

Styling it the way you want should be quite easy then. Comment if you need help with that. I'm happy to help :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文