Aliases: A New Feature in Application Navigation

13 days ago by David Grudl  

Do you have a location in your Nette application that you frequently refer to? Don't want to think about what presenter:action it is? With the new feature in Nette Application 3.2, an elegant solution arrives that will make your work more enjoyable. This is about aliases, which change the way you think about navigation.

Aliases allow you to define easily memorable names for various presenters and actions. Instead of having to use long and complicated identifiers, you can now use a simple and concise alias. For example, instead of Front:Home:default, you can just write @home. Or shorten Admin:Dashboard:default to @admin. All thanks to a new section in the configuration file of your application:

application:
    aliases:
        home: Front:Home:default
        admin: Admin:Dashboard:default
        sign: Front:Sign:in

You don't have to ponder under which presenter the administration of the project you are currently editing falls. Simply create an alias and then write in the template:

<a n:href="@admin">administration</a>

Aliases can be used wherever you work with links – whether in templates, when redirecting using redirect(), and so forth.