Skip to content

tenolo/referer-bundle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tenolo

PHP Version Latest Stable Version Latest Unstable Version Total Downloads Total Downloads License

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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages