2017 © Pedro Peláez
 

contao-bundle contao-newsnavigation-bundle

A bundle to provide a navigation between news articles

image

heimrichhannot/contao-newsnavigation-bundle

A bundle to provide a navigation between news articles

  • Wednesday, January 10, 2018
  • by digitales@heimrich-hannot.de
  • Repository
  • 7 Watchers
  • 1 Stars
  • 111 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 42 % Grown

The README.md

Contao Newsnavigation Bundle

, (*1)

A contao bundle to provide a simple navigation between news articles. It add template variables to go from one news article to the next or the previous article. News article order is calculated by time property., (*2)

Features

  • add Template variables to NewsReaderModule to jump between news articles
  • option to respect news archives set in NewsReaderModule
  • add custom filters via service

Requirements

  • Contao 4.4 (could also work with earlier contao 4 versions)

Installation

Install via composer:, (*3)

composer require heimrichhannot/contao-newsnavigation-bundle

Usage

Template variables

To use this extension, you need to output the template variables in your custom news template., (*4)

Example:, (*5)

<?php if ($this->previousArticle): ?>
    <a href="{{news_url::<?= $this->previousArticle ?>}}" class="previous">
        <?= $this->previousArticleLabel ?>
    </a>
<?php endif; ?>

Newsarchives

To let the navigation respect only news archives set in NewsReaderModule, you find an option in the module backend., (*6)

Developers

Template variables

This extension adds following template tags to the news template model, which you can use in your templates:, (*7)

name description
nextArticle Next (newer) article id
previousArticle Previous (older) article id
nextArticleLabel Next article label ("Next article")
previousArticleLabel Previous article label ("Previous article")

If you want the news title instead the next/previous article label, see #1 how to do this., (*8)

Custom filters

The module allow a simple mechanic to add custom filters for the news navigation. You need to set additional filters to the huh.newsnavigation.newsfilter before the parseArticles Hook (from this module) of the NewsReaderModel is called. You can use following methods:, (*9)

Examples:, (*10)

// add additional database conditions
System::getContainer()->get('huh.newsnavigation.newsfilter')->addFilter('tl_news.newsCategory=?', 'contao4bundles');
// add additions options
System::getContainer()->get('huh.newsnavigation.newsfilter')->setOption('limit', '5');

Custom filter use

You can use the filter in custom way:, (*11)

$filter = System::getContainer()->get('huh.newsnavigation.newsfilter');

// Creates a new filter object which contains all filters
$newFilter = $filter->createCopy();

// Create a new empty newsfilter instance
$newFilter = new HeimrichHannot\NewsNavigationBundle\NewsFilter\NewsFilter();

// Return the filter rules
$filter->getColumns()
$filter->getValues()
$filter->getOptions()

// Override filter rules
$filter->setColumns();
$filter->setValues();
$filter->setOptions();

// Change or return model
$filter->setModel();
$filter->getModel();

The Versions

10/01 2018
10/01 2018
06/12 2017
10/10 2017

1.0.0

1.0.0.0 https://github.com/heimrichhannot/contao-newsnavigation-bundle

A bundle to provide a navigation between news articles

  Sources   Download

LGPL-3.0+

The Requires

 

bundle contao