Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

49 Commits

Repository files navigation

Sitemap

🔧 Sitemap generator component

Introduction

This componenet automaticaly generates sitemap from annotated presenter actions. Found actions are cached to improve performance.

Installation

Install package using composer

composer require nepttune/sitemap

Dependencies

How to use

  • Implement \Nepttune\TI\ISitemap interface and use \Nepttune\TI\TSitemap trait in selected presenters (Those which should have links in sitemap.).
  • Add annotation @sitemap to selected actions.
  • Register \Nepttune\Component\ISitemapFactory as service in cofiguration file.
  • Inject it into eg. SitemapPresenter, write createComponent method and use macro {control} in template file.
    • Just as any other component.
    • Content type is automaticaly set to application/xml.

Example configuration

services:
- Nepttune\Component\ISitemapFactory

You can optionaly provide configuration array and enable hreflang links to be included for each entry (Requires translator in presenter).

parameters:
sitemap:
hreflang: true
services:
sitemapFactory:
implement: Nepttune\Component\ISitemapFactory
arguments:
- '%sitemap%'

Example presenter

class ExamplePresenter implements IPresenter, ISitemap
{
use TSitemap;
/** @var \Nepttune\Component\ISitemapFactory */
protected $iSitemapFactory;
public function __construct(\Nepttune\Component\ISitemapFactory $ISitemapFactory)
{
$this->iSitemapFactory = $ISitemapFactory;
}
public function actionSitemap()
{
$this->getHttpResponse()->setContentType('application/xml');
}
/**
* @sitemap
*/
public function actionExample()
{
}
protected function createComponentSitemap()
{
return $this->iSitemapFactory->create();
}
}

About

🔧 Component for Nette framework which renders as xml sitemap.

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages