By chepatrick1 on
Guys,
I need to update the Drupal navigation menu items without manually doing it or create a Drupal module. Is there a way to write custom code that lives outside the Drupal Framework that uses the Drupal Api?
I'm comfortable with Java so if there is a java solution please let me know but I'm trying to learn php right now.
Comments
<?phprequire_once
gpk
----
www.alexoria.co.uk
gpk
----
www.alexoria.co.uk
Note that only works if you
Note that only works if you are using PHP (Drupal does not have a java API)
What if my file is outside
What if my file is outside the directory? Can't seem to get it to work
I have D5.8 in a 'cms' directory.
ie:
myfile.php
-- cms <--drupal's index.php and folders in here
I tried pointing directly to bootstrap, using:
I get file not found errors. What could this be?
If you mean that
If you mean that cms/includes/bootstrap.inc is not found then try ./cms/includes/bootstrap.inc
Also if you want to have access to Drupal sessions from within your script then you will need to set $base_url in settings.php. This is because the session cookie name is a hash that depends on $base_path, and the latter will be come out different if Drupal is bootstrapped from a different folder location from usual.
gpk
----
www.alexoria.co.uk
gpk
----
www.alexoria.co.uk
Thanks GPK. After trying
Thanks GPK. After trying that URL with no luck I discovered the problem was I didn't use CHDIR properly, works great now!
You can use the bootstrap
You can use the bootstrap PHP code as above, or you can use Java to edit entries in the database directly.
Both options are quite technical though.
Hope that helps!
__________________________________________________________
Mark Theunissen
Code Baboon
Drupal based services
i have little problem. so
i have little problem. so hear me. I learned how to use drupal codes outside drupal folder. Now there is
public_html/drupal and puclic_html/chat folders. Im trying to edit chat so i can log in with drupal name. This can be done by editing form of that chat. (where it ask my name for chat) so i have this code inside my chat's codes form's value="(here)"
so that (here) is code:
but i get errors:
Warning: ini_set() [function.ini-set]: A session is active. You cannot change the session module's ini settings at this time in plaplapla/drupal/sites/default/settings.php on line 144
Warning: ini_set() [function.ini-set]: A session is active. You cannot change the session module's ini settings at this time in plaplapla/drupal/sites/default/settings.php on line 147
Fatal error: Cannot redeclare t() (previously declared in plaplapla/chat/chat.php:243) in plaplapla/drupal/includes/common.inc on line 947
settings.php line 144 is like this:
ini_set('session.save_handler', 'user');
settings.php line 147 is like this:
ini_set('session.use_trans_sid', 0);
chat.php:243 (if that means line) is:
function t($message)
and common.inc line is like this:
}
The message tells you exactly
The message tells you exactly what is wrong. Drupal has a t() function for translation. You are making another one in global namespace so it is not allowed. The session warnings are due to you having 2 bootstraps going. Could you not just put chat.php in module form and do it the drupal way?
there is lots of php files
there is lots of php files and folders with xml things in chat folder so only thing i need is to make that drupal username to work outside drupal folder in that chat. can't put it inside module.
but it is possible if there is drupal module where you could put chat folder inside. (and there is many folders and files inside that chat folder) and then that chat can work. ?
Another thing is why are you
Another thing is why are you having to bootstrap Drupal just to get a user name? You could fetch the cookie/session user id if you are under the same domain to get this information and make web callbacks in your modules to expose APIs to get whatever info you need from Drupal.
If your task you are doing is heavily integrated with Drupal it should be integrated in module form. If it is loosely coupled it should be loosely coupled with web api callbacks. I cannot see any reason why you would want to bootstrap Drupal outside of Drupal unless you were doing something very temporary that is easier with the Drupal API such as importing a bunch of users etc.
I need only user name for
I need only user name for chat, because you don't need anything but name in that chat. I don't know much about codes and this chat is really cool and what i always have wanted. i came here to ask help for this single problem: putting drupal username inside that form in chat.php. and i think it can be done with that bootstrap thing?
Here is my chat code where
Here is my chat code where you can see drupalcode inside form's value:
http://www.text-upload.com/read.php?id=35989&c=1783350
what i have to change to get that thing work?
i mean why does that code work in chat/test.php but not in chat/chat.php??? those form codes must have something to do with it...
Maybe one solution to this problem would be this: i make file code.php and put that bootstrap code inside. Then when i go to code.php there is my drupal username. then there would be some code that sends that name to chat.php's value... or something.
How to use drupal outside
I would like to discuss couple of options here
1- You can use the bootstrap PHP code
2- Services Module - details you can check from this URL http://drupal.org/project/services
however in this case you need to install and enable services module and configure XMLRPC Server and provide access to view, update, delete and add contents through client.
3- Please correct me if i am wrong.
That will not work from the command line
You need to set the following variable if you are bootstrapping drupal from the command line.
PHP Fatal Error
Not sure if this is a Drupal 7 thing or something else but I was getting the error:
And needed to add "define('DRUPAL_ROOT', $drupal_dir);"