> ## Content Index
> Fetch the complete content index at: https://getpublii.com/dev/llms.txt
> Use this file to discover other available public pages before exploring further.

# {{#getPages}} helper

- URL: https://getpublii.com/dev/getpages-helper/
- Published: 2024-08-15T21:02:18.070Z
- Updated: 2024-08-15T21:06:35.208Z
- Description: {{getPages}} is a helper used to retrieve page data regardless of the current context. Syntax: {{#getPages "pageID1,pageID2,pageID3" "before" "after"}} ... {{/getPages}} Example: {{#getPages "PAGE\_ID\_1,PAGE\_ID\_2,PAGE\_ID\_N" "<ul>"…
- Author: Tomasz Dziuda

**{{getPages}}** is a helper used to retrieve page data regardless of the current context.

Syntax:

```handlebars
{{#getPages "pageID1,pageID2,pageID3" "before" "after"}}
...
{{/getPages}}
```

Example:

```handlebars
{{#getPages "PAGE_ID_1,PAGE_ID_2,PAGE_ID_N" "<ul>" "</ul>"}}
<li>
    <h2>{{ title }}</h2>
    <div>{{{ excerpt }}}</div>
</li>
{{/getPages}}
```

Pages are ordered by the ID order in the string.

You can also use the **@index** variable to detect the post number in the specified collection:

```handlebars
{{#getPages "1,2,3" "<ul>" "</ul>"}}
<li>
    <h2>{{ title }}</h2>
    <div>{{{ excerpt }}}</div>
    {{#checkIf @index '==' 0}}
    <p>IT'S THE FIRST ELEMENT!</p>
    {{/checkIf}}
</li>
{{/getPages}}
```

The second parameter creates an HTML prefix, and the third parameter creates an HTML suffix for the generated output.

Additionally, it is possible to enhance the dynamic fetching and display of pages by utilizing the [pages dropdown](#INTERNAL_LINK#/post/158) control from the Theme Settings API, in conjunction with the `concatenate` helper to combine query string options with theme option values. This control allows users to select specific pages to be displayed. Integrating this functionality within your theme involves directly referencing the selected pages through the theme configuration. For instance, if you have a pages dropdown control named `pagesDropdown` in your Theme Settings, its value can be dynamically used with the `getPages` helper, as shown below:

```handlebars
{{#getPages (concatenate  @config.custom.pagesDropdown) "<ul>" "</ul>"}}
    <li>
        <h2>{{ title }}</h2>
        <div>{{{ excerpt }}}</div>
    </li>
{{/getPages}}
```

In this setup, @config.custom.featuredPagesDropdown directly refers to the comma-separated page IDs the user selects through the dropdown control. This approach ensures that the displayed pages can be dynamically controlled via theme settings, offering a high level of customization for theme users.

**IMPORTANT:** It requires availability of the `@website.contentStructure` global variable
