PHPackages                             heimrichhannot/contao-syndication-type-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. heimrichhannot/contao-syndication-type-bundle

ActiveContao-bundle

heimrichhannot/contao-syndication-type-bundle
=============================================

This bundle brings an extendable syndication framework to contao.

0.5.9(2y ago)01.4k1LGPL-3.0-or-laterPHPPHP ^8.1

Since Mar 9Pushed 2y ago6 watchersCompare

[ Source](https://github.com/heimrichhannot/contao-syndication-type-bundle)[ Packagist](https://packagist.org/packages/heimrichhannot/contao-syndication-type-bundle)[ RSS](/packages/heimrichhannot-contao-syndication-type-bundle/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (10)Dependencies (11)Versions (26)Used By (0)

Contao Syndication Type Bundle
==============================

[](#contao-syndication-type-bundle)

[![Latest Stable Version](https://camo.githubusercontent.com/0b6d8b1666e860168c5ac87cd0a360fac572fcd8c23f9783c16b3662175196a9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6865696d7269636868616e6e6f742f636f6e74616f2d73796e6469636174696f6e2d747970652d62756e646c652e737667)](https://packagist.org/packages/heimrichhannot/contao-syndication-type-bundle)[![Total Downloads](https://camo.githubusercontent.com/f82121ffefb73f3a83072b73ac224b6314e38b482ca73f30722424560c8e992e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6865696d7269636868616e6e6f742f636f6e74616f2d73796e6469636174696f6e2d747970652d62756e646c652e737667)](https://packagist.org/packages/heimrichhannot/contao-syndication-type-bundle)

This bundle brings an extendable syndication framework to contao. Syndication can be easily added to your own bundle/module/element. There are already some bundles/entites supported out-of-the-box (see features section).

Features
--------

[](#features)

- out-of-the-box syndication support for
    - article
    - content element
    - [Reader Bundle](https://github.com/heimrichhannot/contao-reader-bundle)
- bundled syndication types:
    - sharing: facebook, email, email feedback, twitter, whatsapp, xing, linkedin
    - export: ical, print
- expandable and customizable syndication framework
    - add pdf export through [PDF Creator Bundle](https://github.com/heimrichhannot/contao-pdf-creator-bundle)
- generated links and link lists implementing [PSR-13](https://www.php-fig.org/psr/psr-13/) `LinkInterface` and `LinkProviderInterface`

Usage
-----

[](#usage)

### Requirements

[](#requirements)

- php ^7.2
- contao ^4.4
- for iCal (.ics) export: `eluceo/ical (^0.16) `
- for PDF export: `heimrichhannot/contao-pdf-creator-bundle`

### Install

[](#install)

1. Install with composer or contao manager

    ```
    composer require heimrichhannot/contao-syndication-type-bundle

    ```
2. Update database

### Article syndication

[](#article-syndication)

You can replace the contao article syndication with the syndication of this bundle.

1. Set `huh_syndication_type.enable_article_syndication` to true (in your project config.yml)
2. Clear your cache and update the database
3. You'll find the new syndication config in your article configuration

### Content element syndication

[](#content-element-syndication)

You can add syndication as a content Element to every article.

1. Set `huh_syndication_type.enable_content_syndication` to true (in your project config.yml)
2. Clear your cache and update the database
3. You'll find the new syndication type in content element type selection

### Reader Bundle

[](#reader-bundle)

1. Create a new reader config element of type syndication
2. Select syndications
3. output the template variable in your template (with raw filter)

### Print content

[](#print-content)

To print your content, you have two options: print the whole page (a simple window.print() link) or use a custom template to print. Print template are written in twig and the file name must start with `syndication_type_print_`, for example `syndication_type_print_default.html.twig`. You can extend [our default](src/Resources/views/syndication/syndication_type_print_default.html.twig) template or create a complete custom template.

While creating you print template, you may want to see a preview without the print popup. To get one, just append `synPrintDebug` parameter to the print url.

Developers
----------

[](#developers)

### Customize link rendering

[](#customize-link-rendering)

If you need more control over the output of the link rendering, you have different options:

#### Override or change default templates

[](#override-or-change-default-templates)

You can override following templates (just use the contao template inheritance with twig templates thanks to [Twig Support Bundle](https://github.com/heimrichhannot/contao-twig-support-bundle)):

- `syndication_provider_default.html.twig`
- `syndication_link_default.html.twig`

It is also possible to create custom versions like `syndication_provider_acme.html.twig`. To use a custom link template, you can use the `BeforeRenderSyndicationLinks` event, pass the option on SyndicationLinkRenderer methods call or decorate the `SyndicationLinkRenderer` service. Change the provider template can be archived by pass the option on SyndicationLinkRenderer methods call or decorate the `SyndicationLinkRenderer` service.

#### Use the BeforeRenderSyndicationLinks event

[](#use-the-beforerendersyndicationlinks-event)

You can customize the options and the links that are rendered through the BeforeRenderSyndicationLinks.

Example (Contao 4.9+):

```
namespace Acme\ExampleBundle\EventListener;

use HeimrichHannot\SyndicationTypeBundle\Event\BeforeRenderSyndicationLinksEvent;
use Terminal42\ServiceAnnotationBundle\Annotation\ServiceTag;

/**
 * @ServiceTag("kernel.event_listener", event="HeimrichHannot\SyndicationTypeBundle\Event\BeforeRenderSyndicationLinksEvent")
 */
class SyndicationBeforeRenderSyndicationLinksEventListener
{
    public function __invoke(BeforeRenderSyndicationLinksEvent $event): void
    {
        $options = $event->getLinkRenderOptions();
        $options['template'] = 'syndication_link_acme';
        $event->setLinkRenderOptions($options);
    }
}
```

#### Decorate the `SyndicationLinkRenderer` service

[](#decorate-the-syndicationlinkrenderer-service)

You can customize all options by decorating the `SyndicationLinkRenderer` service. If you're not familiar with that, it sounds complicated, but symfony make it easy and here is a working example (just change namespaces and class names):

```
# services.yml
services:
  App\Syndication\DecoratedLinkRenderer:
    decorates: HeimrichHannot\SyndicationTypeBundle\SyndicationLink\SyndicationLinkRenderer
    arguments: ['@App\Syndication\DecoratedLinkRenderer.inner']
```

```
use HeimrichHannot\SyndicationTypeBundle\SyndicationLink\SyndicationLinkRenderer;

class DecoratedLinkRenderer extends SyndicationLinkRenderer
{
    protected SyndicationLinkRenderer $inner;

    public function __construct(SyndicationLinkRenderer $inner)
    {
        $this->inner = $inner;
    }

    public function renderProvider(SyndicationLinkProvider $provider, array $options = []): string
    {
        // Tell the renderProvider method to call the customized render method
        return $this->inner->renderProvider($provider, array_merge($options, [
            'render_callback' => [$this, 'render']
        ]));
    }

    public function render(SyndicationLink $link, array $options = []): string
    {
        // add or customize link attributes
        $options['attributes']['class'] = trim(($options['attributes']['class']  ?? '').' btn btn-primary');
        // don't output template dev comments
        $options['disable_dev_comments'] = true;
        // a custom template (pass only the name)
        $options['template'] = 'a_really_custom_link_template';
        // override the link content
        $options['content'] = "Click THIS link!";

        return $this->inner->render($link, $options);
    }
}
```

### Add syndications to your bundle

[](#add-syndications-to-your-bundle)

Syndication bundle is build to be reused. You can easily add it to your code.

1. Add all needed fields to your dca

    - We recommend creating a listener to the loadDataContainer Hook
    - Add fields and configuration with `SyndicationTypeDcaProvider::prepareDca($table)`
    - Generate the palette with `SyndicationTypeDcaProvider::getPalette()` and place it where it should be. You can pass a boolean parameter to get the palette seperated by legends or not.

    ```
    use HeimrichHannot\SyndicationTypeBundle\Dca\SyndicationTypeDcaProvider;

    function prepareTable(string $table, SyndicationTypeDcaProvider $syndicationTypeDcaProvider)
      {
          $dca = &$GLOBALS['TL_DCA']['tl_article'];
          $dca['palettes']['default'] = str_replace(
            'printable',
            $syndicationTypeDcaProvider->getPalette(false),
            $dca['palettes']['default']
          );
          $syndicationTypeDcaProvider->prepareDca($table);
      }
    ```
2. Generate syndication links in your controller/module/listener/...

    - create an instance of `SyndicationContext`
    - generate syndication links with `SyndicationLinkProviderGenerator::generateFromContext()` (will return a `SyndicationLinkProvider` instance, which is a collection of `SyndicationLink` instances)
    - render the syndication links with `SyndicationLinkRenderer::renderProvider()` (will return the rendered links as string. You could also use/create a custom link renderer)

    For easy of implementation you can access all of these services through `SyndicationManager`.

    ```
    use HeimrichHannot\SyndicationTypeBundle\Manager\SyndicationManager;

    class ExampleController {

        private SyndicationManager               $syndicationManager;

        public function addSyndication(string $title, string $content, array $itemData, ExampleModel $config): string
        {
            // $title: A title for the syndication
            // $content: What should be shared. Can be a teaser text or a rendered template.
            // $itemData: The data of the entity to share
            // $config: The configuration. Typical the model data (row) of the configuration. Maybe the same as item data.
            $context = $this->syndicationManager->createContext($title, $content, $itemData, $config->row());

            // See next paragraph
            $this->doExport($context);

            $provider = $this->syndicationManager->getLinkProviderGenerator()->generateFromContext($context);
            $rendererContext = $this->syndicationManager->createLinkRendererContextFromModel();

            return $this->syndicationManager->getLinkRenderer()->renderProvider($provider, $rendererContext);
        }

    }
    ```
3. Add export support.

    - this should be done, where your content to export is completely configured and fully rendered (or can be fully rendered). In the most cases, this can be done where you generate the syndication links, but maybe it must be done on a later point.
    - create a `SyndicationContext` instance

- run `ExportSyndicationHandler::exportByContext()`

    ```
    use HeimrichHannot\SyndicationTypeBundle\Manager\SyndicationManager;
    use HeimrichHannot\SyndicationTypeBundle\SyndicationContext\SyndicationContext;

    class ExampleController {

        private SyndicationManager               $syndicationManager;

        private function doExport(SyndicationContext $syndicationContext): void
        {
            $this->syndicationManager->getExportSyndicationHandler()->exportByContext($context);
        }

    }
    ```

### Add custom syndication type

[](#add-custom-syndication-type)

1. Create a SyndicationType class
    - the class must implement `SyndicationTypeInterface` (or `ExportSyndicationTypeInterface`)
    - you can (and we recommend) extend `AbstractSyndicationType` or `AbstractExportSyndicationType` (for syndication types which do some export like pdf, print or ical), which already implement their corresponding interfaces
2. Implement the abstract methods
    - `getType()` - return an alias for the syndication type
    - `generate()` - generate the syndication link. A `SyndicationContext` instance is passed, a `SyndicationLink` instance must be returned. We recommend to use `SyndicationLinkFactory` to create the `SyndicationLink` instance.
3. Optional: If your SyndicationType extends one of the abstract classes, your can override following methods:
    - `getCategory()` - customize the syndication category. There are two categories predefined as constants in `AbstractSyndicationType`: `share` and `export`, but it is possible to use a custom category
    - `getPalette()` - if your syndication type depends on additions configuration, you can set the syndication type palette here
4. Optional: If your SyndicationType extends one of the abstract classes, your can use the following helper methods:
    - `getValueByFieldOption()` - return a configuration value from the context (shorthand so you don't have to do all the array validation)
    - `appendGetParameterToUrl()` - utils to append a get parameter to an url. Useful for creating export links
5. Register service type class as service with `huh.syndication_type.type` service tag
6. Create an Event Subscriber for `AddSyndicationTypeFieldsEvent`,`AddSyndicationTypePaletteSelectorsEvent` and `AddSyndicationTypeSubpalettesEvent` to add custom dca fields and subpalettes

Configuration reference
-----------------------

[](#configuration-reference)

```
# Default configuration for extension with alias: "huh_syndication_type"
huh_syndication_type:

    # Enable this option to replace the default contao article syndication with syndication type bundle article syndication.
    enable_article_syndication: false
    enable_content_syndication: false
```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 87.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~48 days

Recently: every ~73 days

Total

24

Last Release

781d ago

PHP version history (3 changes)0.1.0PHP ^7.2

0.5.3PHP ^7.4 || ^8.0

0.5.9PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/28ad3224d8727b622ebd229840eea6b9dbcb83eb0bd609e6ce65b614830ff538?d=identicon)[digitales@heimrich-hannot.de](/maintainers/digitales@heimrich-hannot.de)

---

Top Contributors

[![koertho](https://avatars.githubusercontent.com/u/12064642?v=4)](https://github.com/koertho "koertho (49 commits)")[![vvohh](https://avatars.githubusercontent.com/u/75325799?v=4)](https://github.com/vvohh "vvohh (3 commits)")[![iSteuding](https://avatars.githubusercontent.com/u/142582530?v=4)](https://github.com/iSteuding "iSteuding (2 commits)")[![AlexejKossmann](https://avatars.githubusercontent.com/u/32612134?v=4)](https://github.com/AlexejKossmann "AlexejKossmann (1 commits)")[![davidsky7](https://avatars.githubusercontent.com/u/89909249?v=4)](https://github.com/davidsky7 "davidsky7 (1 commits)")

### Embed Badge

![Health badge](/badges/heimrichhannot-contao-syndication-type-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/heimrichhannot-contao-syndication-type-bundle/health.svg)](https://phpackages.com/packages/heimrichhannot-contao-syndication-type-bundle)
```

###  Alternatives

[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6939.5M343](/packages/drupal-core-recommended)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
