Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By ecksley on
I would like to get the raw URLs of the nodes collected in my Views query. I can't seem to find a Field that is devoted to this purpose.
Yes, there is a node link field, but I need the raw URL itself to pass it into a multimedia piece.
Yes, I can grab the nid and scrap together a working URL but I would much rather use the URL alias.
Is there:
1) some sort of a Drupal function that will output a URL alias if I pass it the NID?
2) a field I'm just not seeing withing the Views Fields that will yield the URL alias?
Thanks so much for your time!
Edited by WorldFallz - moved to appropriate forum.
Comments
_
you could probably get this working by using drupal_get_path_alias in a http://drupal.org/project/views_customfield.
Thank you!
Thank you!
I am using a tpl.php to theme the View so I just inserted the function call in the markup... didn't even need the customField module, although it's great to know it exists.
For anyone else using a tpl.php the code I used to grab to correct alias looked like the following:
Sorry I posted in the wrong forum. I just thought this was theming related.
Thanks Ecksley, i needed just
Thanks Ecksley, i needed just that to do something similar...
Good info! Thanks.
Good info! Thanks.
In case someone does want to
In case someone does want to output url_alias in views using customfield php
Great from Google Merchant and Ubercart product nodes.
Facebook Share button in a view
Thanks. I used this piece of code to generate a FB share button that points to the intended node for each displayed node in the view. See here.
https://www.martin.postma.website/
Hi, im using this code on my
Hi, im using this code on my custom field:php code in my view. but it doesn't get language of the node. what it gets its just node path alias. any advice on this one would be highly appreciated
You can simplify your code
You can simplify your code considerably by using Drupal's API more:
--
Jakob Persson - blog
Leancept – Digital effect and innovation agency
Tidy solution Jakob, but...
I came accross this answer and it does exactly what I wanted in a very succinct way, but for some reason it doesn't work - unless I use 'print' twice! - Any idea why this might be? If I write this in my page.tpl.php:
I get no output, but if i write this:
Then I get the raw node ID?
Thank you so much, this
Thank you so much, this worked for me.
- Nigerian web designers
Awesome
I was looking for the same thing. Thanks!
In views 3.x you can use
In views 3.x you can use "Path" field with option "Use absolute path" in Rewrite field group.
This is what I needed.
This is what I needed.
Path does not show
Weird for me even in Views 3.x using with Services, the Path does not fill up.
prints the complete url with correct alias
prints the complete url with correct alias