Sự khác nhau Route, Path, URL, URI, Link, Menu item trong Drupal 8

Sự khác nhau Route, Path, URL, URI, Link, Menu item trong Drupal 8

Sometimes, diving in to try and help work on something in an open source project can leave you feeling stupid, lost and confused. Generally, you'll find you are not alone. Sharing the problem, and the solution when you find it, can be helpful to build your own understanding, but also might help others too. So, just in case I'm not the only one feeling lost and confused about why the path / route / link issue in Drupal is so complex, I thought I'd share some of my confusion and a little ray of light that might help unravel this tangle of related terminology.

>> Giới thiệu PHP và JavaScript Closures, cài đặt Drupal 8

>> Hội thảo Drupal 8 xoay quanh sprint designed tại Belgium

In the Drupalverse, we use IRC to connect with each other.  So I popped into channel and asked: 

Can someone describe how drupal uses these terms? route, path, url, uri, link, menu item - or point me to a reference?

Angela Byron generously responded with a rough outline of definitions, which I've fleshed out a bit below with some references.


"this URL goes to this PHP code, and can only be accessed by these kind of people."
As far as I can tell, this is a relatively new concept for Drupal with routing and controllers, replacing the hook-menu system we had previously. Here's a couple of references that might be helpful if you want to build a deeper understanding.

update: Peter Wolanin wrote to say 

In D6 & D7 the menu system was the routing system. "this is a relatively new concept for Drupal" is not correct. We re-wrote things in terms of Symfony classes, but the basic concepts are actually the same. In Drupal 7 the data is stored in the {menu_router} table, in D8 it's been moved to just {router}. The big different in Drupal 8 vs D7 is that a single path may match more than one route name. In D7 a path is identical to the route name, so there cannot be more than one.


Uniform Resource Locator eg. "https://www.drupal.org/community" It's generally the address we use to find content on the web.


Uniform Resource Identifier is often confused with URL because it's so similar. See the URI wikipedia page for more information. I'm not sure if or how Drupal distinguishes between the use of URIs, URLs and URNs (Uniform Resource Names), but let's save that yak to shave on another day.

The Build a module team made a video that describes the difference between a URL and a URI
What the difference is between a URI and a URL (a Drupal how-to)

update: Peter adds

Recent patches landing in core have adopted a URI field for storage for the Link Field, so you will (in the database at least) now start to see URIs like entity:node/5 and user-path:/blog


The path is like a pathway to find content eg. admin/content but because it can be an alias, it may not actually represent the location of a file on disk, which helps lead to some of the complexity under the hood in Drupal, and the confusion about when to use http://example.com/blog/yakshaving, /blog/yakshaving, or node/5

update: Peter notes 

The Path section should mention at least the idea of "base path" - the prefix including the subdirectory that needs to be adding to an "internal path" to make a relative URL. It would also be worth noting that by adopting the new routing system we are trying to remove, as much as possible, use of or reference to the internal path in favor of routes when referring to a Drupal page.


the base path will usually just be a "/" unless Drupal is installed in a subdirectory.


<a href="/foo">foo</a> - This one seems pretty straightforward - it's the HTML markup used to point to a URI or path.

Menu item

A link in a menu - which could be pointing to a route, path or URI.

update: and final note

The term "menu item" here is wrong. It should be "menu link". In D6 & D7 a "menu item" is the thing that's been replaced by a "route object" in D8. However, I will acknowledge that in D6 and D7 there is a lot of code that may use variables or comments referring to a menu link as a menu item - this is generally a reflection of logic carried forward from D5 where they were actually the same thing.

Hope that helps you, it certainly helps me to lay it all out like this. And, just in case you're wondering how I fell down this rabbit hole, this relates to a series of critical issues holding up the release of Drupal 8.  If you can help, please get involved  or buy a ticket in my chook raffle to help fund the Drupal 8 Accelerate initiative.

Bạn thấy bài viết này như thế nào?: 
No votes yet




Dich vu khu trung tphcm

Dich vu diet chuot tphcm

Dich vu diet con trung

Quảng Cáo Bài Viết

CSS website
Tối ưu hóa SEO cho CSS website

Bài viết này sẽ hướng dẫn các bạn cách tối ưu CSS, nó sẽ giúp cải thiện được tốc độ tải trang phần nào. Trong quá trình thực hiện các dự án SEO và công việc Onpage của mình, trong bài viết này mình sẽ giúp các bạn hình dung được khi viết CSS cũng phải đảm bảo một số tiêu chí để website của bạn tốt hơn trong mắt của robot google.

www.Sothichweb.com được làm mới
www.Sothichweb.com được làm mới

Phong cách thiết kế luôn có sự thay đổi, sự đơn giản sẽ là xu thế lâu dài bởi cuộc sống ngày càng phức tạp và chúng ta sẽ muốn tiếp nhận những cái đơn giản, đơn giản không phải là bỏ đi những chức năng cần thiết mà bỏ đi những thứ ít cần thiết hơn

DrupalCon Austin monitoring session submissions
DrupalCon Austin monitoring session submissions

This is my fifth DrupalCon monitoring session submissions. My fifth time nervously counting the submissions as they come rolling in, first at a trickle, maybe 20 in a week. Then stagnation, followed by a bit of a panic - did we remember to tell people??