Hi all and sorry for this stupid question (any RTFM is wellcome).
I want to create a page (say foo.php) inside a bar/ directory that when call display me (via browser) some info stored in a variable ($foo). So I have $foo, I have my themes, I have my bar/foo.php url, but how can I do an all in one ?
This is my simple code for bar/foo.php:
<?
require_once '../includes/bootstrap.inc'; drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
$page = "io sono la pagina"; echo theme('page',$page);
?>
And the php-error is :
PHP Fatal error: require_once() [<a href='function.require'>function.require</a>]: Failed opening required './includes/cache.inc' (include_path='/opt/www/newzb/:.:..') in /opt/www/newzb/includes/bootstrap.inc on line 895
If I move foo.php from bar/ to / and changhe ../includes in ./includes all works.
Where is my error ?
M.
On Wed, 09 Jan 2008 01:46:24 +0100 Davide Michel 'ZioBudda' Morelli michel@ziobudda.net wrote:
Hi all and sorry for this stupid question (any RTFM is wellcome).
I want to create a page (say foo.php) inside a bar/ directory that when call display me (via browser) some info stored in a variable ($foo). So I have $foo, I have my themes, I have my bar/foo.php url, but how can I do an all in one ?
This is my simple code for bar/foo.php:
<? require_once '../includes/bootstrap.inc'; drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); $page = "io sono la pagina"; echo theme('page',$page); ?>
And the php-error is :
PHP Fatal error: require_once() [<a href='function.require'>function.require</a>]: Failed opening required './includes/cache.inc' (include_path='/opt/www/newzb/:.:..') in /opt/www/newzb/includes/bootstrap.inc on line 895
If I move foo.php from bar/ to / and changhe ../includes in ./includes all works.
I bet because paths in bootstrap.inc are relative. Wouldn't it be better to write a custom template for that page? You can redefine the *whole* page. You just have to write a custom page.tpl.php. It is described at page 115 in Pro Drupal Developement.
There are some modules that let you change the first page too etc...
I wouldn't work against the CMS and its api.
Ivan Sergio Borgonovo ha scritto:
I bet because paths in bootstrap.inc are relative. Wouldn't it be better to write a custom template for that page?
Nope, I need to use it for other pages, too (if it is possible).
You can redefine the *whole* page. You just have to write a custom page.tpl.php. It is described at page 115 in Pro Drupal Developement.
My scenario is this: I have a script that I need to incorporate into my template. The output of this script is generated from some data insert into a form that the script display. The script display this form into output page, too. When a news version of this script is ready, i need to delete the old one and insert the last script. So a drupal module is impossible to mantein.
I wouldn't work against the CMS and its api.
Me, too.
M.
On Wed, 09 Jan 2008 10:03:38 +0100 Davide Michel 'ZioBudda' Morelli michel@ziobudda.net wrote:
Ivan Sergio Borgonovo ha scritto:
I bet because paths in bootstrap.inc are relative. Wouldn't it be better to write a custom template for that page?
Nope, I need to use it for other pages, too (if it is possible).
If you write a module you can use -page.tpl.php for as many pages as you wish.
My scenario is this: I have a script that I need to incorporate into my template. The output of this script is generated from some data insert into a form that the script display. The script display this form into output page, too. When a news version of this script is ready, i need to delete the old one and insert the last script. So a drupal module is impossible to mantein.
If the script was not written in a way it can be easily embedded well... it won't be easy to embed it ;)
If they did something like
file1.php: <?php ... require_once('bla.php'); ...
bla.php: <?php $globalvariable="blabla";
function a() { } function b() { } ?> <strong>some html outside functions</strong>
It is hard you'll ever be able to include bla.php to reuse functions a() and b() in a clean way.
Once you've to deal with such code you'll have to do dirty things.
Of course you can wrap everything inside a function in a module being careful to take care of the scopes and paths.
mymodule.php function myfunc() { require_once('bla.php'); };
Quoting Davide Michel 'ZioBudda' Morelli michel@ziobudda.net:
This is my simple code for bar/foo.php:
<? require_once '../includes/bootstrap.inc'; drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); $page = "io sono la pagina"; echo theme('page',$page); ?>
And the php-error is :
PHP Fatal error: require_once() [<a href='function.require'>function.require</a>]: Failed opening required './includes/cache.inc' (include_path='/opt/www/newzb/:.:..') in /opt/www/newzb/includes/bootstrap.inc on line 895
If I move foo.php from bar/ to / and changhe ../includes in ./includes all works.
Where is my error ?
Bootstrap and all other Drupal includes are coded to be relative to the current directory. You need to chdir('..') and then include ./include/bootstrap.inc.
Earnie -- http://for-my-kids.com/ -- http://give-me-an-offer.com/
Earnie Boyd ha scritto:
Bootstrap and all other Drupal includes are coded to be relative to the current directory. You need to chdir('..') and then include ./include/bootstrap.inc.
IT WORKS!!!! <?
chdir(".."); require_once './includes/bootstrap.inc'; drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
$page = "io sono la pagina"; echo theme('page',$page); ?>
TNX TNX TNX
Now I'm doing more test. TNX TNX