Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/infinityloop-dev/sitemap
:wrench: Component for Nette framework which renders as xml sitemap.
https://github.com/infinityloop-dev/sitemap
component nette nette-component php sitemap
Last synced: about 1 month ago
JSON representation
:wrench: Component for Nette framework which renders as xml sitemap.
- Host: GitHub
- URL: https://github.com/infinityloop-dev/sitemap
- Owner: infinityloop-dev
- License: mit
- Created: 2018-04-17T11:06:19.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-05-01T13:34:23.000Z (over 4 years ago)
- Last Synced: 2024-11-21T18:26:32.867Z (about 2 months ago)
- Topics: component, nette, nette-component, php, sitemap
- Language: PHP
- Homepage: https://www.infinityloop.dev
- Size: 44.9 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Sitemap
:wrench: 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
- [nette/application](https://github.com/nette/application)
- [nette/di](https://github.com/nette/di)
- [nette/caching](https://github.com/nette/caching)## 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();
}
}
```