Using $base_url to build a link in a computed field, I get this error:

Notice: Undefined variable: base_url in eval() (line 1 of F:\wamp\www\mysite\sites\all\modules\computed_field\computed_field.module(468) : eval()'d code).

Is it a way to get the site base URL in a computed field?


This is a global scope variable and you can access it by using $GLOBALS['base_url'] instead or calling the core base_path() function to pull it into your computed field definition.


Before using $base_url, You need to declare it just like below

global $base_url;

After declaring you can use $base_url in your code.

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.