Questions tagged [uri]

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

Filter by
Sorted by
Tagged with
2 votes
1 answer
78 views

Can I know what I'm looking at from the URL?

I think on Drupal 7 I had previously used something like menu_get_object() to find out what content I was on. For example, with mysite.com/content/my-page, it would tell me that this was a node, its ...
user avatar
0 votes
1 answer
39 views

Get an entity URL, not its path alias

How can I get the URL of an entity without its alias? This code just gives me the path alias, but what I actually want would be, for example, /en/node/1 instead of /en/node/my-title. $entity->toUrl(...
user avatar
  • 605
0 votes
0 answers
29 views

How do I unset a link?

I want to programmatically decide whether to render a link or not. This should apply to all links e.g anchor tags (no wysywigs) Not only menu links. I tried using hook_link_alter. /** * Implements ...
user avatar
0 votes
1 answer
34 views

How to add the domain to the Link field?

I activated the Link module that is part of Drupal core. I want to add on the user profiles fields with links to social pages and limit the domain used in the link. How can I add such restriction to ...
user avatar
0 votes
1 answer
32 views

Linkit Module - Pointing the link's title attribute to a custom field. Hook available? [closed]

Currently the Linkit module delivers the link's title attribute by pulling the related node's title field. We would like it to point to another field in the node. How can we achieve this? I looked ...
user avatar
  • 137
0 votes
0 answers
11 views

How to change an exposed filter destination url?

I have a blog view that contains some exposed filters. Using the Views exposed filter blocks i added the filters into the articles that are listed in the blog. The problem is that when i use the ...
user avatar
  • 1
1 vote
2 answers
58 views

How to apply nofollow and target_blank on external links in text created with CKEditor?

When I create a node, I often need to add links to external websites in the text. I want all the external links to open in a new tab and I want them to have a nofollow. The body field uses CKEditor. ...
user avatar
0 votes
0 answers
23 views

How to get id from context filter in views?

Please tell me how can I get the node id from the url in views? Is it possible to pull it out of the context filter so that after passing it to the form via the prepopulate module? I am creating a ...
user avatar
0 votes
0 answers
11 views

How do I get the path for an image referenced in an entity field? [duplicate]

I'm using <img src="{{ node.field_listing_location.0.entity.field_listing_location_image.entity.uri.0.value }}"> to get the path of an image referenced from a taxonomy field. What I ...
user avatar
  • 21
0 votes
0 answers
24 views

How to add contextual filter?

I am working with books in drupal 8. I want to display a specific page("table of contenets") on the sidebar whenever any page of that book is accessed. "table of contents" is a ...
user avatar
1 vote
0 answers
30 views

Filter GeoJSON feed on a value in the path

I have GeoJSON feed, created with a view in Drupal 7, that I want to filter on a path value in the url of the loaded page (/path/%). The feed is loaded as an Openlayers map on a page. The feed seem to ...
user avatar
0 votes
1 answer
54 views

How to get the base URL of a site in Queue API?

I am trying to get the base url of the drupal 8 website in a queue process but I am getting http://default as the base url. What am I missing here? public function testUrl() { global $base_url; ...
user avatar
0 votes
1 answer
75 views

Gracefully handle URL/URI/Link exceptions when using Link field formatter?

Occasionally I am encountering an error along these lines: The website encountered an unexpected error. Please try again later.InvalidArgumentException: The URI 'XYZ' is invalid. You must use a valid ...
user avatar
  • 26.5k
1 vote
1 answer
112 views

How to get product variation media file url using jsonapi?

I'm using the following jsonapi GET request to retrieve product variations for a product: /jsonapi/commerce_product/default/0ea927c7-b62d-45c9-8bec-dc3d16215276/variations?include=field_images ...
user avatar
-5 votes
1 answer
98 views

Why does a query string return a 404 error? [closed]

I recently upgraded from Drupal 8 to Drupal 9 and noticed a problem that occurs when the URL has a query string. For example for the following URL Drupal throws a 404 page not found. https://example....
user avatar
  • 37
0 votes
1 answer
77 views

How can I disable these URLs?

In Drupal 7, the following URLs show the same node. http://www.example.com/node/5 http://www.example.com/node/5/randomtext1 http://www.example.com/node/5/randomtext2 http://www.example.com/node/5/...
user avatar
  • 431
0 votes
1 answer
140 views

How do I hide static media file URLs?

I have developed a website in Drupal 7. Right now I have a requirement: A page should display a PDF file (already generated). Only authenticated users should have access to view or download this file, ...
user avatar
0 votes
1 answer
92 views

How can I create a Link to an URL containing a fragment identifier?

Is it possible to create a Link to a node with a hash in url (for opening a special Tab). I use: Link::createFromRoute('Title', 'entity.node.canonical', ['node' => 77]); And I want to link to: &...
user avatar
  • 59
0 votes
2 answers
75 views

How to prevent proxy URLs in link field from being encoded?

Others appear to have similar issues to Drupal 8/9 encoding URLs in the link field though I see no solutions. We're a library site and have many links for our patrons to external database websites ...
user avatar
0 votes
0 answers
246 views

How to get the URL of remote video inserted by media field in block or paragraph twig?

How to get the URL of remote video inserted by media field in block or paragraph twig? I am using the paragraphs module to create video galleries from youtube videos. When I use {{ content....
user avatar
0 votes
1 answer
137 views

Drupal and reverse proxy: How to make Drupal aware that it's protocol is HTTPS?

I have a reverse proxy Docker container in front a Drupal container on a Docker host. My reverse proxy container is https://hub.docker.com/r/jwilder/nginx-proxy The public site URL is https://ahora-...
user avatar
  • 205
0 votes
1 answer
39 views

Find a URL inside Twig file from content made from another content type (referenced/ has a relationship)

I'm new to Drupal, and have stumbled across this issue. I have entries (entry) that are blogs held inside a blog_listing. E.g. {% for entry in content.field_blog_listing_entries|field_target_entity %} ...
user avatar
0 votes
1 answer
128 views

How do I get the current URL in a rule?

I am trying to make a Rule where after the user logs in they are redirected to the front page except when they are setting their first time password or resetting their password To do it I want to use ...
user avatar
  • 313
5 votes
3 answers
577 views

How can I restrict external URLs in link field to allow only certain domains?

After creating a Link field and use the Link with service icon format, I find out that there is no option to restrict external URLs to external domains that I want For example, if I only want to allow ...
user avatar
  • 75
0 votes
1 answer
522 views

How do I get the public file URI for a media file from jsonapi?

I have an audio file that is stored as Media of type Audio. Now I want to get the link to that file that is usually displayed to site users via jsonapi. For example, when the media entity is rendered, ...
user avatar
3 votes
1 answer
163 views

How to get the destination nid from an URL object

In a preprocess function I want to access the destination node id via the URL object I cannot find any method that will return the node id for me but I can clearly see that it holds the node id. (see ...
user avatar
  • 263
0 votes
1 answer
120 views

How do I prevent node enumeration?

I am currently developing a Drupal 8 site that will consist of one only central content type with a minimal menu structure. The user is supposed to navigate the site only by using a search/filter form ...
user avatar
  • 269
2 votes
2 answers
1k views

How do I get the current destination URL query parameter?

Does anyone know to how to get the destination in a template file? At the moment I an getting the destination parameters in a preprocess function. // Get destination params. $variables['...
user avatar
2 votes
2 answers
628 views

How to dynamically manipulate canonical entity URLs

I've got a project with a multi-user / multi-domain environment. There is one "main" portal like www.myproject.com and for every registered user with a specific custom permission ...
user avatar
  • 4,908
0 votes
2 answers
455 views

Use url of media field in view twig

I need to output the url for field_slide_media in views-view-unformatted--carousel.html.twig. I can output the entity ID using: {{ view.field.field_slide_media.value(view.result[i]) }} I would like ...
user avatar
  • 115
3 votes
2 answers
362 views

What is the best practice for writing a link to the screen through t()?

In Drupal 7, one could do the following one line:: t('Visit !mylink', ['!mylink' => l('my website', 'http://example.com')]); But that no longer works in Drupal 8 or 9 😞. So far, I've tried this:...
user avatar
  • 14.8k
0 votes
0 answers
1k views

Programmatically get the current url of the page from where a Webform in a dialog has been loaded

The below link will open the webform (contact) in a dialog: <a href="/form/contact" class="btn btn-success webform-dialog webform-dialog-normal">Contact</a> this same link has been ...
user avatar
2 votes
1 answer
404 views

$base_root problem

In /core/lib/Drupal/Core/DrupalKernal.php the $base_root shows incorrect value: Line 1113 protected function initializeRequestGlobals(Request $request) { global $base_url; // Set and ...
user avatar
0 votes
1 answer
121 views

Alter a path alias depending on a node property

I use the Pathauto module and I'm trying to get, for the same content type, two different path aliases depending on a Boolean field that content type has. I would like to have a path alias like ...
user avatar
3 votes
1 answer
183 views

When should I use the Url::fromRoute method instead of "new Url"

I'm finding that these two PHP snippets yield the same result: $arr['query']['confirm'] = 'y'; $text = t('Click here.'); $url = new Url('my_route.import', [], $arr); // Three arguments. $link = Link::...
user avatar
-5 votes
1 answer
1k views

How to link to a file in twig template

I'm trying to link to a file in a view. I have a field in the view that outputs the link if I use it like this: <div class="product-cta-view-pdf"> {{ fields.field_notice.content }} </div&...
user avatar
  • 101
1 vote
1 answer
969 views

Render media url in node--page.html.twig

I have an Entity reference field field_video. It's a core Media field with a Reference type of Remote video. Because I use this field_video in my Hero section I need some additional markup here. ...
user avatar
  • 1,265
0 votes
1 answer
648 views

Get argument from current URL in twig to generate a link with that argument

I'm trying to get an argument from search page URL so that I can pass that argument to a link. For example I have this URL for a search results page: http://domain.com/site-search?search_api_fulltext=...
user avatar
0 votes
1 answer
181 views

How to create programmatically multiple URL alias of same taxonomy term?

I have category cars and I want to create its URL alias according to the region like if the user location is Australia than URL will mysite/australia/cars similar if the user location is USA than URL ...
user avatar
  • 3,175
0 votes
0 answers
89 views

Ckeditor pasted url links become hyperlinks

We have disabled 'Convert URLs into links'. When you copy a url link from a browser url field like: drupal.org. Your clipboard contains the FQDN: https://www.drupal.org/. When you past this into ...
user avatar
1 vote
1 answer
843 views

Notice: Trying to get property 'nid' of non-object

In Drupal\rsvplist\Form\RSVPForm->buildForm(), I wrote this to get the current nid: $node = \Drupal::routeMatch()->getParameter('node'); $nid = $node->nid->value; I get this error: ...
user avatar
0 votes
0 answers
61 views

Redirect user to a specific page

I'm new to drupal. And I have a project that has a search block on the home page that redirects the user to a page based on the user search terms. Everything works fine but I have a FAQ page that ...
user avatar
  • 1
0 votes
0 answers
28 views

how to change the keyword for URL search with new search

I have a problem with the search API function. The first time I enter the keyword into the search field which will show the results and the URL like this for example: www.avc.com/avs/search/search-...
user avatar
0 votes
1 answer
119 views

Generate automatic URL alias removing words

I'm trying to create a topic page for "internet of things", but each time I create the page I notice the URL slug removes the word "of" in it. By default Generate automatic URL alias is checked. The ...
user avatar
0 votes
1 answer
81 views

How to print the URL of a title field?

I'm trying to print out the url path from the title in my twig template however I haven't been successful so far. Printing out the title containing the link works fine using: {{content.title}} ...
user avatar
  • 1
0 votes
1 answer
574 views

Custom Page routing

I created a custom page type called 'Angular page' and a custom twig template for it which loads my angular scripts and prints the <app-root> tag. I set the page URL to /angularpage and the ...
user avatar
  • 233
0 votes
1 answer
894 views

Programmatically auto-submit a Webform after visiting its URL

I am wondering whether it's possible to programmatically auto-submit a Webform after visiting its URL and to save the user from a 'submit' button click. The below webform can be accessed via /form/my-...
user avatar
0 votes
0 answers
283 views

How to redirect to the previous page after submission of a form in a block

I have a view of nodes of type task. I created a block with an inline task create form (using form block module) The block is next to the view on the same page. Question: After creating a new task by ...
user avatar
  • 566
1 vote
1 answer
993 views

Get Absolute url using hook_preprocess_node

We are attempting to change the $variables['url'] from a relative to absolute URL within the mymodule_preprocess_node() hook. The $variables['url'] is displayed as a <a> element within our node--...
user avatar
  • 2,416
0 votes
1 answer
225 views

Get 404 for url specified in module.routing.yml

I am new to Drupal and I got stuck with the problem that I don't know how to debug even: I have made a simple module 'final', its structure: Applications/MAMP/htdocs/drupal_dir_1/modules/final > ...
user avatar

1
2 3 4 5
23