How to get full url of the current page in bigcommerce stencil code?

384 Views Asked by At

I'm trying to access either below: https://testing.com/cat/?page=5 or /cat/?page=5

via the bigcommerce object. However, after research I only found the below code:

{{ settings.request.absolute_path }}

This will only return me /cat/

but I'm missing of /cat/?page=5

So can anyone help me to how to achieve the above? any way I can access this?

I've below code written: (of course below wont work with absolute path)

{{#if settings.request.absolute_path '===' 'https://testing.com/cat/?page=5' }}
    <meta name="description" content="The fifth page of cat products available." >
{{/if}}

bigcommerce object

2

There are 2 best solutions below

1
Tony McCreath On

pagination.category.current should work for you on category pages. It may be different on Brand pages.

I like the idea.

2
Keith McGowan On

Not sure this is the most efficient solution, but you could try something like:

{{#if settings.request.absolute_path '===' '/cat/'}}
  {{#if pagination.category.current '===' 5}}
    <meta name="description" content="The fifth page of cat products available." >
  {{/if}}
{{/if}}

Or you could try incorporating the {{concat}} helper with something like:

{{#if (concat settings.request.absolute_path '?page=5') '===' 'https://testing.com/cat/?page=5' }}
  <meta name="description" content="The fifth page of cat products available." >
{{/if}}

Both will get the job done, but the second one might be closer to the answer you are looking for.