PHPackages                             itech-world/sulu-article-twig-extension-filter-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. itech-world/sulu-article-twig-extension-filter-bundle

ActiveSulu-bundle[Templating &amp; Views](/categories/templating)

itech-world/sulu-article-twig-extension-filter-bundle
=====================================================

SuluArticleTwigExtensionFilterBundle extends the Sulu CMS to enable article retrieval in TWIG without ElasticSearch

v1.1.4(2mo ago)41002MITPHPPHP ^8.2CI passing

Since Sep 23Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/steeven-th/SuluArticleTwigExtensionFilterBundle)[ Packagist](https://packagist.org/packages/itech-world/sulu-article-twig-extension-filter-bundle)[ RSS](/packages/itech-world-sulu-article-twig-extension-filter-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (8)Dependencies (2)Versions (11)Used By (0)

 [![Itech World logo](./doc/images/logo.png)](./doc/images/logo.png)

Article Twig Extension Filter Bundle for [Sulu](https://sulu.io)
================================================================

[](#article-twig-extension-filter-bundle-for-sulu)

### Developed by [Steeven THOMAS](https://github.com/steeven-th)

[](#developed-by-steeven-thomas)

 [ ![GitHub license](https://camo.githubusercontent.com/f8df3091bbe1149f398a5369b2c39e896766f9f6efba3477c63e9b4aa940ef14/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e) ](LICENSE) [ ![Sulu compatibility](https://camo.githubusercontent.com/34064f3c25a97dd4eaa0bfb7da870c3b6ec1e8c0d16c8d347a37a2556918bd4d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f73756c755f636f6d7061746962696c6974792d2533453d332e302d6379616e) ](https://sulu.io/)

ArticleTwigExtensionFilterBundle extends the Sulu CMS to enable article retrieval in TWIG without ElasticSearch 📂 Requirements
--------------

[](#-requirements)

- PHP ^8.2
- Sulu ^3.0

🛠️ Features
-----------

[](#️-features)

- TWIG extension `sulu_article_load_by_uuid allowing` an article to be retrieved by its identifier
- TWIG extension `sulu_article_count_published` for counting the number of published articles
- TWIG extension `sulu_article_load_recent` allowing you to retrieve the latest recent articles
- TWIG extension `sulu_article_load_recent_paginated` allowing you to retrieve the latest recent articles with pagination

📝 Installation
--------------

[](#-installation)

### Composer

[](#composer)

```
composer require itech-world/sulu-article-twig-extension-filter-bundle
```

### Symfony Flex

[](#symfony-flex)

If you don't use Symfony Flex, you can add the bundle to your `config/bundles.php` file:

```
return [
    // ...
    ItechWorld\SuluArticleTwigExtensionFilterBundle\ItechWorldSuluArticleTwigExtensionFilterBundle::class => true,
];
```

Instructions
------------

[](#instructions)

#### Retrieve an item using its UUID

[](#retrieve-an-item-using-its-uuid)

Use `sulu_article_load_by_uuid`. Possible parameters:

- `uuid` : The UUID of the article
- `locale` : The locale of the article

#### Count the number of published articles

[](#count-the-number-of-published-articles)

Use `sulu_article_count_published`. Possible parameters:

- `locale` : The locale of the article
- `filters` : An array of filters to apply to the query

#### Retrieve the latest recent articles

[](#retrieve-the-latest-recent-articles)

Use `sulu_article_load_recent`. Possible parameters:

- `limit` : The number of articles to retrieve
- `templateKeys` : An array of template keys to filter the articles
- `locale` : The locale of the article
- `ignoreWebspace` : Ignore webspace and return all articles
- `categoryKeys` : An array of category keys to filter the articles
- `tagNames` : An array of tag names to filter the articles
- `webspaceKeys` : An array of webspace keys to filter the articles (only if `ignoreWebspace` is false)

#### Retrieve the latest recent articles with pagination

[](#retrieve-the-latest-recent-articles-with-pagination)

Use `sulu_article_load_recent_paginated`. Possible parameters:

- `limit` : The number of articles to retrieve
- `offset` : The offset of the articles to retrieve
- `templateKeys` : An array of template keys to filter the articles
- `locale` : The locale of the article
- `ignoreWebspace` : Ignore webspace and return all articles
- `categoryKeys` : An array of category keys to filter the articles
- `tagNames` : An array of tag names to filter the articles
- `webspaceKeys` : An array of webspace keys to filter the articles (only if `ignoreWebspace` is false)

### Returned Data Structure

[](#returned-data-structure)

All functions return articles as arrays with the following properties:

PropertyTypeDescription`uuid`stringUnique identifier of the article`id`intDatabase ID`title`stringArticle title`description`stringExcerpt description (from "Excerpt &amp; Taxonomies" tab)`excerptTitle`stringExcerpt title (from "Excerpt &amp; Taxonomies" tab)`excerptMore`string"Read more" text (from "Excerpt &amp; Taxonomies" tab)`url`string|nullArticle URL`template`string|nullTemplate key used`stage`stringPublication stage (`live`, `draft`)`locale`stringArticle locale`published`DateTime|nullPublication date`workflowPlace`stringWorkflow status`categories`CollectionCategories (from "Excerpt &amp; Taxonomies" tab)`tags`CollectionTags (from "Excerpt &amp; Taxonomies" tab)`created`DateTimeCreation date`changed`DateTimeLast modification date`content`arrayAll template data (custom fields from your XML template)### Examples of usage

[](#examples-of-usage)

Create a `templates/articles.html.twig` file with the following content:

```
{% extends 'base.html.twig' %}

{% block content %}

    {% set paginatedResult = sulu_article_load_recent_paginated(12, 0, ['article-template-key'], app.request.locale) %}
    {% set recentArticles = paginatedResult.articles %}
    {% set pagination = paginatedResult.pagination %}

    {% if recentArticles %}
        {% for article in articles %}
            {{ article.title }}
        {% endfor %}
    {% endif %}

{% endblock %}
```

**Note :** Replace `article-template-key` with the key of your XML template.

For pagination, you can create an AJAX route in a Controller and use `ItechWorld\SuluArticleTwigExtensionFilterBundle\Service\ArticleService`.

Example:

```
