There is a route in routing.uml

 category: path: /category defaults: { _controller: MainBundle:Client:showCategory } 

presenter on the action, which renders the page to which the styles are connected in this way: <link rel="stylesheet" href="bundles/MainBundle/css/category.css"> . At the same time, everything works, when switching to /category styles are successfully loaded. There was a task to transfer to the route with the id category parameter. I do this by example. In routing.uml :

 category: path: /category/{id} defaults: { _controller: MainBundle:Client:showCategory } requirements: id: '\d+ 

And now, after switching to /category/1 page content is displayed, but without styles. What you need to fix to return the css?

Symfony version 3.1

  • The solution was to use a different format for setting the path to css: href="<?php echo $view['assets']->getUrl('bundles/MainBundle/css/category.css‌​') ?>" - QA_Zero

1 answer 1

Maybe you just because of access to a different url changes the current location. And your css path is inserted as "relative to the current document". Therefore, styles and not visible.

Try to make a link to the style, using the path relative to the root of the site (if it is, of course, not forbidden to do for any reason). Namely, add a slash at the beginning of the path and set the full path to the file with styles.

 <link href="/css/style.css" rel="stylesheet"> 
  • The slash at the beginning does not help ((And this path is the complete one, starting from the horse directory `web`. But thanks anyway. - QA_Zero