Are there any way to get site's base URL value in a token within view to use in its header and field(s).

My local developments is on drupal installation in a sub-directory while on server it is on a domain.


You can use global $base_url; if you are using the PHP filter.

| improve this answer | |

You may use https://www.drupal.org/project/views_base_url

  1. Add field Global: Base url
  2. Hide it
  3. Use token [base_url] D7 {{ base_url }} D8
| improve this answer | |

I don't know how to get a token with the base URL but if you are rewriting links, etc. you can start with a slash like href="/mydirectory/mypage and Drupal will automatically add the base URL.

| improve this answer | |
  • Starting with slash does not produce correct link in my local installation on subdirectory. – Junaid Jun 28 '12 at 9:07
  • 2
    You may have better luck with the Pathologic module: drupal.org/project/pathologic – Patrick Kenny Jun 28 '12 at 9:53

In No results behavior I have selected Global: Unfiltered text, and

< a href = "/search-landing-sell-property-type"> Click here </a>

results in the correct path to the page.

| improve this answer | |
  • 2
    Does it work if you are running Drupal in a subdirectory? (e.g. http://www.mydomain.com/drupal/…) – thirdender Mar 14 '13 at 23:15
  • Yes. In my case I have Drupal running in a subdirectory. – VivMajor Apr 26 '13 at 12:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.