By Duplika on
I'm sure there's a way, like using the PHP snippets but adding the database information but I can't seem to make it work.
What I want is to print node titles from a particular term outside Drupal's directory. Any know how to do this? I've searched and Googled with no luck.
Comments
What do you mean "outside
What do you mean "outside Drupal's directory"?
Do you mean to write a php application which connects to Drupal's database, runs queries and prints some results?
I'd like to know exactly
I'd like to know exactly that. How do I use any of the PHP snippets in a website in a different directory, outside Drupal (but on the same domain)?
--
Duplika | Web Hosting
(no title)
Oh, I see... The snippets have been written to be used from within a running Drupal installation, but I remember someone doing something like this with a script.
For this to work in Drupal 5.2 you need to set $cookie_domain='example.com'; in settings.php, or else you will always be an "anonymous" visitor. In older versions that is not necessary. And of course you need to be logged-in as a user with the proper permissions.
Thanks!
Thanks for your answer cog.rusty, it seems to work for me but I get some errors.
I'd like to make a list of latest nodes from a given type so, with your code, I use:
And where I use it, I get:
Do you have any clue what could be wrong?
--
Duplika | Web Hosting
(no title)
Make sure that your index2.php file does not contain spaces, empty lines or anything else outside the
<?php ... ?>tags. That's what usually causes a "headers already sent" error.Or don't use a closing
?>tag at all (like all drupal modules do).Sometimes this also happens with some text editors which add an invisible Unicode "bom" marker character at the beginning of the file.
I looked for empty spaces or
I looked for empty spaces or lines without success and finally got it working like this:
And I don't get any errors but problem now is that everything after the second part of the php code doesn't show on the browser. And if I delete the last line
return;, it does show but with all the special characters like accents (á é í, etc.) with weird symbols.--
Duplika | Web Hosting
I'm also trying to do this
I'm also trying to do this "old way", not using bootstrap. At the beggining of the php, I use mysql_connect, I run the query on the SQL database and that's it but I can't manage to make this:
... work without bootstrap or any other Drupal file.
--
Duplika | Web Hosting
(no title)
db_query(), db_fetch_object() and l() are Drupal functions (the {node} braces too). They do not exist without Drupal.
(no title)
No idea what is happening. I can reproduce your error message ("at index2.php:6") only if I add 5 empty lines on the top of the file.
Of course the last "return" would terminate the script and it was not needed anyway.
Thanks for your patience
Thanks for your patience cog.rusty. See here for what happens with the site if I take out the return.
Everything is ok except that every special character is displayed as a symbol. For example, "Además" is displayed as "Adem�s".
--
Duplika | Web Hosting
(no title)
I see...
My browser says that the character encoding is utf-8 (as Drupal would be)
The page source says "charset=iso-8859-1"
If I force my browser to iso-8859-1, then the bottom text is ok but the last link's text is ruined.
Are there characters coming from two different application on that page? From another one's in iso-8859-1 and fom drupal in utf-8? Which one comes from the script?
--------
By the way, if you have static text to convert, there is little free Windows text editor, Notepad2 (http://www.flos-freeware.ch/notepad2.html), which I use all the time to convert text to/from utf8. Except if you are familiar with php iconv.
That was it! Drupal's
That was it! Drupal's content "came" with utf-8 and the page was in iso-8859-1! I've changed the page to utf-8 and everything is perfect now. Thanks a lot cog.rusty!
--
Duplika | Web Hosting
subscribed
subscribed
me too
subscribe
Rocks !
and work ! thanks a lot.