tenolo / referer-bundle
Provides simple functions to use and set referer.
Installs: 132
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: ^5.6|^7.0
- league/uri-manipulations: ^1.5
- league/uri-schemes: ^1.2
- psr/http-message: ^1.0
- symfony/config: ^3.4|^4.0
- symfony/dependency-injection: ^3.4|^4.0
- symfony/framework-bundle: ^3.4|^4.0
- symfony/http-kernel: ^3.4|^4.0
- symfony/twig-bundle: ^3.4|^4.0
- twig/twig: ^2.11|^3.0
This package is auto-updated.
Last update: 2024-10-19 21:27:05 UTC
README
Referer Bundle
Helpful in Twig Templates. Allows you to set a static referer that can be set across multiple page views using the session to get back to a specific page using a Twig function. This can be used to generate a "Back" button.
Install instructions
First you need to add tenolo/referer-bundle
to composer.json
:
Let Composer do it for you.
$ composer require tenolo/referer-bundle
or do it manually
{ "require": { "tenolo/referer-bundle": "~1.0" } }
Please note that dev-master
latest development version.
Of course you can also use an explicit version number, e.g., 1.0.*
.
Usage
To go back to the last page
{# check for a static referer #} {% if referer_has() %} <a href="{{ referer_uri() }}">Go back</a> {% endif %}
If no static referer was set, the referer from the header of the request is used.
To set a static referer.
<a href="{{ path('route_name_of_next_page', { param: value })|referer_query }}">Next Page</a>
The link is manipulated so that the library remembers the current page. If the Twig function "referer_uri" is called on one of the later pages, a link is generated that links back to the current page.