bodokaiser
bodokaiser

Reputation: 15742

Symfony2: How to handle dynamic "nav" bar

I got a nav/action bar on the left side of the document which allows me to manage data between three entities by clicking on a link.

This makes it a little complicated. There are three types of state which render:

  1. Static URLs (/image/add) - Those URL's don't change and always do the same

  2. Dynamic URLs (server side) - For example when I do a "showAction" I can render the slug of the showen entity into the url's

  3. Dynamic URLs (client side) - For example when I do an "indexAction" I pick out an entity and jQuery sets the id of the entity into the url (/image/2383382.jpg/edit)

These three states appear sometimes together which makes it quite hard to mentain and code clearly. Also different layer get mixed up

I think there are two ways to handle this better:

  1. Javascript - Only (prefered choice) I write a jQuery plugin which gets an JSON-Object as input and the plugin handles everything

  2. Symfony Service A Symfony Service handles the urls and only has to get rendered by twig unfortunatly still javascript is required to select an entity without rendering edit, show actions for each entity extra

What do you think about my ideas? Are there other/better solutions?

Regards

Upvotes: 0

Views: 282

Answers (1)

Maciej Pyszyński
Maciej Pyszyński

Reputation: 9374

You always should generate urls by {{ path('route_name', { 'param1': 'value' }) }}

And for maintain routes in JS use FOSJsRoutingBundle

Upvotes: 1

Related Questions