@@ -647,25 +647,7 @@ But if you pass extra ones, they will be added to the URI as a query string::
647
647
Generating URLs from a Template
648
648
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
649
649
650
- The most common place to generate a URL is from within a template when linking
651
- between pages in your application. This is done just as before, but using
652
- the ``path() `` function to generate a relative URL:
653
-
654
- .. configuration-block ::
655
-
656
- .. code-block :: html+twig
657
-
658
- <a href="{{ path('blog_show', {'slug': 'my-blog-post'}) }}">
659
- Read this blog post.
660
- </a>
661
-
662
- .. code-block :: html+php
663
-
664
- <a href="<?php echo $view['router']->generate('blog_show', array(
665
- 'slug' => 'my-blog-post',
666
- )) ?>">
667
- Read this blog post.
668
- </a>
650
+ To generate URLs inside Twig, see the templating chapter: :ref: `book-templating-pages `.
669
651
670
652
Generating URLs in JavaScript
671
653
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -717,29 +699,6 @@ method::
717
699
$this->generateUrl('blog_show', array('slug' => 'my-blog-post'), UrlGeneratorInterface::ABSOLUTE_URL);
718
700
// http://www.example.com/blog/my-blog-post
719
701
720
- From a template, in Twig, use the ``url() `` function (which generates an absolute URL)
721
- rather than the ``path() `` function (which generates a relative URL):
722
-
723
- .. configuration-block ::
724
-
725
- .. code-block :: html+twig
726
-
727
- <a href="{{ url('blog_show', {'slug': 'my-blog-post'}) }}">
728
- Read this blog post.
729
- </a>
730
-
731
- .. code-block :: html+php
732
-
733
- <?php
734
- use Symfony\C omponent\R outing\G enerator\U rlGeneratorInterface;
735
- ?>
736
-
737
- <a href="<?php echo $view['router']->generate('blog_show', array(
738
- 'slug' => 'my-blog-post',
739
- ), UrlGeneratorInterface::ABSOLUTE_URL) ?>">
740
- Read this blog post.
741
- </a>
742
-
743
702
.. note ::
744
703
745
704
The host that's used when generating an absolute URL is automatically
0 commit comments