Questions tagged [uri]

A "Uniform Resource Idendifier" identifies a resource on a network.

Filter by
Sorted by
Tagged with
62 votes
14 answers
132k views

How to get the valid URL of a Link field from within a Twig template?

I have a Link field named field_my_link (machine name). Within a Twig template I can get the link's URL value with this: {{ node.field_my_link.uri }} If inside the Link's URL there is an external ...
Andrea's user avatar
  • 1,267
61 votes
7 answers
103k views

How to get the base URL of a site

My site is on http://drupal8.local/. How do I get the drupal8.local part of that URL? Url::fromRoute('<'current'>') or base_path() returns the path parth of the URL; For example, for http://...
Jasodeep Chatterjee's user avatar
50 votes
5 answers
73k views

How do I get the node ID from the URL?

So far, I came across these 3 functions in Drupal 7, but I am not really sure what the difference between them is, and which is more appropriated to get the node ID in a block preprocess function. ...
silkAdmin's user avatar
  • 2,814
43 votes
9 answers
46k views

How do I change a theme based on the URL?

I have a Drupal instance running on example.org. Which has a theme X installed and activated. Now for a limited period an event is supposed to be held on the site for which a special section has been "...
Samyak Bhuta's user avatar
37 votes
6 answers
67k views

How do I get the full URL of the current page?

I need to get the full URL of the currently opened page. I use the following code, but it returns http://localhost/mysite/page_name. $path = isset($_GET['q']) ? $_GET['q'] : '<front>'; $link =...
Abdulrahman's user avatar
  • 1,806
30 votes
4 answers
62k views

How do I get the node URL in a Twig template?

I am trying to get the node URL in a Twig template. {{ content.node_link }} returns the full link, but I only need the URL. How do I retrieve the node URL?
inalto's user avatar
  • 521
20 votes
4 answers
13k views

Clean urls - auto path alias - how to remove accents (Á É Ó Í Ñ ) from the urls?

I´m using Drupal 7.9 and pathauto 7.x-1.0-rc2 I want to remove the accents from the paths and replace them with normal letters Á=A É=E Ó=O Í=I Ñ=N etc. I'm using a taxonomy field type and node ...
PartySoft's user avatar
  • 1,036
20 votes
1 answer
13k views

Load a file entity by URI

Is there a way to load a file by URI in Drupal 8? In Drupal 7, it is possible using the following code. $uri = 'public://file.xyz'; // Take a look at: file.inc::file_load_multiple $files = ...
voleger's user avatar
  • 950
20 votes
2 answers
41k views

How do I change the base URL?

In Drupal 7, we can quickly change the base URL of the website. How can I do this, in Drupal 8?
spacecodeur's user avatar
  • 1,329
15 votes
5 answers
37k views

how to get the absolute path for files based on fid

How can i get the absolute path for a file based on the fid? Sorry if this is a repeat, I did a search but was unable to find the answer.
Russ's user avatar
  • 295
12 votes
4 answers
17k views

drupal_goto(request_uri()) replaces my '?', '=' and '&' in url

I need to redirect user from a page with example.com/node/add/dispo?arg1=1&arg2=2 to the same type of URL. But when I simply do a drupal_goto(request_uri());, it redirects my user to example.com/...
Gregory Kapustin's user avatar
11 votes
5 answers
766 views

How to start views at %nid position (from path)?

I have a portfolio showing somes nodes (views3 + views slideshow using cycle). Everything works fine, I've a default path /portfolio to access to it. However, I'm trying to set a path for each slide. ...
Doomsday's user avatar
  • 211
10 votes
4 answers
39k views

How do I get the public url of a file from the uri or filename

I'm using php from with a view (Views PHP) I'm trying to extract the real url of a file from a file reference. I am able to get the the uri of the file and or the filename. What drupal function can I ...
user379468's user avatar
  • 2,520
10 votes
8 answers
31k views

How to detect the current URL?

I would like to add a body class in D6 if you are on a specific page(s) currently in my template.php I have: if url('the/path') { add the body class... } but that function doesn't seem to be ...
hollywood3224's user avatar
10 votes
4 answers
4k views

How to force the canonical URL to use http?

On our page we use the Metatag module to show a canonical meta tag. In the configuration we use the [current-page:url:absolute] token. This works fine, but the problem is, that whether the page gets ...
jumper's user avatar
  • 344
9 votes
2 answers
19k views

How do I redirect to an external URL?

Drupal 7 has drupal_goto() that would allow redirecting to an external url. The change record indicated that ControllerBase::redirect is the method to be called in D8. https://www.drupal.org/node/...
Tanay Sai's user avatar
  • 404
9 votes
2 answers
31k views

How to change my base URL

I have built a website using drupal. Now, the base URL is http://xxx.xxx.xxx.xxx/drupal. But I want to change base URL as http://xxx.xxx.xxx.xxx How do I do? Thanks.
user6919's user avatar
  • 305
9 votes
5 answers
11k views

How to get a user's profile picture URL?

I need to get the user's profile picture using the following code: \Drupal::service('renderer')->renderPlain(\Drupal\user\Entity\User::load(\Drupal::currentUser()->id())->user_picture->...
user1960's user avatar
  • 131
9 votes
1 answer
11k views

Programmatically set URL Alias when creating node in form plugin

I'm currently importing data from a database to create nodes based on them. My node save code looks like this $node = \Drupal\node\Entity\Node::create([ 'type' => 'issue', ...
Amy's user avatar
  • 5,662
9 votes
1 answer
20k views

How do I enable clean URLs with Nginx?

I'm using Drupal 7.x. I have achieved to make it work without clean URLs. Investigating, I have understood that I should create a vhost for each drupal site and enable clean URLs with the following ...
Eduardo's user avatar
  • 131
9 votes
2 answers
8k views

Get an image with style url from an URI in twig

So thanks to 4k4 I finally managed to get my original image URI in a field template via item.content['#item'].entity.uri.value and with {{ file_url(item.content['#item'].entity.uri.value) }} I ...
Jannis Hell's user avatar
8 votes
2 answers
21k views

Getting arguments from URL

How do I get arguments from the URL? in other words, what is the equivalent of the arg() function of Drupal 7 and previous versions?
Karthikeyan Manivasagam's user avatar
8 votes
1 answer
6k views

How to get the Route object from an URI?

If I have a Url object, or even a simple string representation of path such as /node/2, how can I get the full Route object?
pfrenssen's user avatar
  • 1,137
8 votes
3 answers
14k views

Get image's URL as a token for use in Views' replacement pattern

I need to get an image's full URL path as a token that I can use as a replacement pattern in Views. I'm trying to have one thumbnail image link to a larger image. I have the larger image excluded ...
Brad's user avatar
  • 181
8 votes
2 answers
8k views

How to find the list of 'paths' on my site?

I recently became the administrator of a Drupal site. I am attempting to configure various blocks on the page, and have so far only succeeded in removing them altogether. The configuration menu tells ...
Matthew's user avatar
  • 81
8 votes
1 answer
8k views

What is the URL to set the admin theme?

The URL to change the admin theme isn't the same in Drupal 7 compared to 6. What is the new URL?
Paul Sheldrake's user avatar
8 votes
3 answers
8k views

Clean URL's Test Failed in D 7

I am tired of finding solution for this issue.. I have tried allmost allthings. But It doesn't work for me. What I have tried is given below: uncommenting RewriteBase / Changing the syntax of ...
Fero's user avatar
  • 1,547
8 votes
3 answers
11k views

How to convert URL aliases back to node ID

I wonder how to convert a URL path back to it's own node (node/nid). I wish to get the original node ID from a given path. e.g. path = "news/my-news" ..and trace it back to get it's own original URL,...
Adamtan's user avatar
  • 651
7 votes
5 answers
29k views

Get the site base url in template.php

How do i get the base url in template.php? None of the below works. global $base_url; global $base_path; global $base_root;
esafwan's user avatar
  • 1,348
7 votes
2 answers
11k views

Why are tokens added to image URLs?

When I'm use the image_style_url(), function I got this token at the end of the URL: ?itok=yjoxJwQh. Drupal uses a different token for styles and script, eg ?mk4o7m. How does this affect caching and ...
Nikola's user avatar
  • 233
7 votes
3 answers
6k views

How to make URL arguments available as tokens in Rewrite Results of a Field in a View?

Is it possible to make URL arguments, e.g. http://mysite.com/arg1/arg2/arg3 available as tokens in the rewrite results settings for a field in views e.g. for the above these would be available for ...
therobyouknow's user avatar
7 votes
5 answers
4k views

Proper way to get the base path when including an image from a module?

When using just drupal_get_path() to include an image from a module directory, this produces non-existent urls when using language prefixes. I've seen a couple of modules prepend base_path() to deal ...
arjan's user avatar
  • 1,463
7 votes
7 answers
5k views

How to display a block on only the listed pages using wildcard and excluding subpages?

I have a block I'm displaying using block setting's "Only the listed pages". I'm using a wild card asterisk to show the block on any pages following about-us/. For example: about-us/* The problem is ...
Sam's user avatar
  • 583
7 votes
1 answer
8k views

Clean URLs disabled even though module-rewrite is on

I have a manually installed LAMP environment on Ubuntu 15.10 Desktop and when I came to install Drupal 8 on it i've seen that clean URLs are disabled, so I turned on the Apache2 (2.4.12) rewrite ...
user avatar
6 votes
7 answers
24k views

How can I enable clean URLs?

I installed Drupal 7 on Wamp Server. I can't find any checkbox or link to enable clean URLs; I see only the Run the Clean URL Test button. How can I enable clean URLs?
sjkon's user avatar
  • 217
6 votes
3 answers
15k views

How to get the URL of a file located in the theme folder?

Is there a way to get the URL of an image located in the theme folder? Or just get the URL of the theme folder?
Andrey Rudenko's user avatar
6 votes
3 answers
17k views

How can I get an absolute path to a theme?

Is there a Drupal function that returns the absolute theme path? Or is there a canonical / base practice way of doing this correctly returning the theme path? What I've found so far is this: <?...
chrisjlee's user avatar
  • 6,550
6 votes
4 answers
3k views

User URLs based on the usernames

Is there a module that changes the user URL from "user/1" to "user/username"?
Mythrillic's user avatar
6 votes
3 answers
8k views

Get raw and relative path of a file uri

I have a file with an uri and I want to get its raw and relative path. Uri: public://videos/Test Video.mp4 Path: /sites/default/files/videos/Test Video.mp4 I found already a way to do this: $...
btemperli's user avatar
  • 402
6 votes
1 answer
1k views

Can I access public:// from inside a module?

I need to load an image that's uploaded to the public folder from within a module In the module itself: function mymodule_dashboard() { GLOBAL $user; $profile = profile2_load_by_user($user->...
Damon's user avatar
  • 821
6 votes
4 answers
16k views

How to add canonical links on ALL URL's?

What is the best way to get canonical links on ALL URL's in D7? I see nodes already have relative canonicals but I have a site with a lot of non node URL's that also need canonicals. I added code to ...
dibs's user avatar
  • 818
6 votes
1 answer
3k views

Load an entity from a URI

I have a URI 'entity:node/27' and I want to load this entity, but I cannot find the correct helper function or class to use. I do not want to explode the string or regex the string, I am fairly sure ...
Rob Holmes's user avatar
6 votes
1 answer
4k views

how to make url string absolute?

In order to get entity link, I'm using: $entity->getTranslation($language)->url(); So it gives me : /en/node/21 But I want this url to be absolute. How to pass $options = array('absolute' =&...
Sugandh Khanna's user avatar
6 votes
2 answers
118 views

Get more drupal.org project usage information

Choosing a Drupal module has become an art-form. Deciding if the module is active, used frequently, growing in usage, etc. is important. I'm a site builder. https://drupal.org/project/usage has lot'...
Sonicthoughts's user avatar
6 votes
1 answer
9k views

Drupal behind a SSL offloading reverse proxy -- is this config correct?

We are transitioning an existing drupal installation to run as a SSL-only site behind a SSL offloading proxy. Drupal itself has no SSL and is running on port 80 on apache. We've got what we think is ...
Wyatt Barnett's user avatar
6 votes
3 answers
7k views

How do I create a Url object from the public file URI?

How can a Url object be created from a file URI? Using the URI for a public file as a parameter for Url::fromUri() gives this error. UnexpectedValueException: External URLs do not have internal ...
maskedjellybean's user avatar
6 votes
1 answer
4k views

Add url alias with parameter (?foo=bar)

I need to create urls aliases like this: /mypath?foo=bar&foo2=bar2 (source) -> /foo/bar (alias) via standard drupal alias url add (admin/config/search/path), but when I insert that link in ...
ZioBudda's user avatar
  • 1,182
5 votes
3 answers
1k views

How to restrict access to a node via node/12 and allow access via a path like content/sometitle?

Problem: I want to restrict direct node access using node number www.example.com/node/12 and allow access using pathauto alias www.example.com/content/sometitle to anonymous user. This user should be ...
suneel's user avatar
  • 51
5 votes
1 answer
21k views

How to add additional url parameters?

I would like to know how I can include additional URL parameters to a given link? ie: 'news?pid=3' <?php print $path='news?pid=3'; ?> This returns page not found error as the '?' is getting ...
Jons's user avatar
  • 237
5 votes
3 answers
8k views

How do I reset the clean URLs?

Another developer has sent me a completed Drupal 7 website. When I installed it, the home page uses clean URLs, which don't work; example.com/index.php?q=/node/123 does work. When I go to example....
frosty's user avatar
  • 623

1
2 3 4 5
23