1

i want to get Drupal base path in views rewrite result. but rewrite result doesn't support PHP code.

how can i add Drupal base path to replacement patterns in views rewrite result? i try installing some modules like entity api, token but it doesn't help.

i know there is http://drupal.org/project/views_php and i get base path with php code but it has a dev release.

  • What exactly are you trying to do? Display the base path itself or perhaps build an absolute link? If that's the latter, you can use Views built-in functionality to "Output this field as a link" and set the "Use absolute path" flag. – jamix Apr 17 '13 at 20:45
  • for example change src of img tag can't be done with your suggestion. – user1903750 Apr 17 '13 at 21:03
  • Then you have to use a field template I'm afraid. – jamix Apr 18 '13 at 8:37
1

You can do this in the theme layer by overwriting the template and calling base_path(). If you are displaying Fields, you can overwrite the template for the field you want to rewrite.

| improve this answer | |
0
  1. Its pretty safe to use views_php I have been using this without any problem so far.
  2. May be without the module you can do the following things 2.1 Check the Output this field as a link 2.2 Give the link path let say your domain is www.xyz.com and you want to link this field to path www.xyz.com/xyz, so in the link path field jus give xyz and it will automatically pick your url.

look at screenshot if it helps.enter image description here

| improve this answer | |
  • thank you. but i want base path change dynamically when i upload site from localhost to server or if site domain change. – user1903750 Apr 17 '13 at 19:54
  • I believe domain still will be dynamic this way, just make sure you are not putting the domain in the link path instead your putting the internal page path . – arpitr Apr 17 '13 at 22:34
  • In the Drupal, basepath automatically change dynamically when you upload site from localhost to server or you change domain if you have not set "$base_url" variable in "settings.php". – Jayendra Kainthola Apr 18 '13 at 3:38
  • @arptir. another thing is what if i want base path as image src? – user1903750 Apr 18 '13 at 8:26
  • i ma not sure but it seems you need an image which can take you to home page,is it right? if yes you can add that image field and out put that image field as link and link path as <front> is it close to what you need? – arpitr Apr 18 '13 at 12:14

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.