Using l() function from external script
In Drupal 6 I have an external script to create some nodes. I would like to use the l() function to create links to other nodes using 'node/n' as the path. However, since my script is running at doc root*, the l function (actually the url() function) is prepending the current directory to the url. So instead of: http://www.example.com/this/that/then-some I'm getting: http://www.example.com/scripts/this/that/then-some Thoughts? Jeff * later this script will move outside of doc root
Are you loading the l() files through bootstrap? If so, try setting $base_path after you do your bootstrap. Jamie Holly http://www.intoxination.net http://www.hollyit.net On 7/5/2011 6:11 PM, Jeff Hartman wrote:
In Drupal 6 I have an external script to create some nodes. I would like to use the l() function to create links to other nodes using 'node/n' as the path. However, since my script is running at doc root*, the l function (actually the url() function) is prepending the current directory to the url.
So instead of:
http://www.example.com/this/that/then-some
I'm getting:
http://www.example.com/scripts/this/that/then-some
Thoughts?
Jeff
* later this script will move outside of doc root
Yes, dumb mistake. I realized that I was setting this before bootstrap(ing). But glad I posted because of the confirmation of what I needed to do and for Randy's suggestion to look into utilizing Drush. :) Thanks! On Jul 5, 2011, at 5:12 PM, Jamie Holly wrote:
Are you loading the l() files through bootstrap? If so, try setting $base_path after you do your bootstrap.
Jamie Holly http://www.intoxination.net http://www.hollyit.net
On 7/5/2011 6:11 PM, Jeff Hartman wrote:
In Drupal 6 I have an external script to create some nodes. I would like to use the l() function to create links to other nodes using 'node/n' as the path. However, since my script is running at doc root*, the l function (actually the url() function) is prepending the current directory to the url.
So instead of:
http://www.example.com/this/that/then-some
I'm getting:
http://www.example.com/scripts/this/that/then-some
Thoughts?
Jeff
* later this script will move outside of doc root
The bottom line is: Make your external script a drush script, so Drupal will be bootstrapped and set up correctly. There are loads of advantages to this - mostly that you don't have to track down every problem you find like you're doing right now. Alternately, you can bootstrap Drupal yourself, but drush is the best way to do it. -Randy On Tue, Jul 5, 2011 at 4:11 PM, Jeff Hartman <lists@jeffhartman.com> wrote:
In Drupal 6 I have an external script to create some nodes. I would like to use the l() function to create links to other nodes using 'node/n' as the path. However, since my script is running at doc root*, the l function (actually the url() function) is prepending the current directory to the url.
So instead of:
http://www.example.com/this/that/then-some
I'm getting:
http://www.example.com/scripts/this/that/then-some
Thoughts?
Jeff
* later this script will move outside of doc root
-- Randy Fay Drupal Module and Site Development randy@randyfay.com +1 970.462.7450
participants (3)
-
Jamie Holly -
Jeff Hartman -
Randy Fay