Skip to content

[QA]: paginate with db-collection #49

@4external

Description

@4external

What happened?

Hi!

What is best way for implement tag 'paginate' with collection(from DB)?

When adding 'metaobjects' Drop (proxy to DB) in assigns,

        $assigns = compact(
            'metaobjects'
        );
        $sectionContext = $environment->newRenderContext( data: $assigns );

and then use template

{% paginate metaobjects[type].values by 3 %}  
  {% for m in metaobjects[type].values %}
    <p>{{ m.title }}</p>    
  {% endfor %}
{% endpaginate %} 

It's show only 3 from many, it's ok, but when in template need access to original collection outside paginate, like this

<p>test assign [type] limit 5</p>
{%- assign mo_collection = metaobjects[type].values -%}
{%- for mo in mo_collection limit: 5-%}
<p>{{ mo.title }}</p>
{%- endfor -%}

I get only three objects, not five from original proxy (it's emulate shopify collections, if direct access - first page with 250 and sort by title asc)

In Paginate tag I put 'metaobjects' array(not proxy) to ActiveScope.
$context->setToActiveScope($rootName, $items);

Also tried $context->set($varName, $items);

but no luck.

I will appreciate any thought to resolve this thing.

How to reproduce the bug

n\a

Package Version

0.9

PHP Version

8.2

Which operating systems does with happen with?

No response

Notes

sorry for using bug report, QA issue template is get 404 from GitHub.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions