I would like to have my own country database in Drupal.
The database exists as an mysql db in the same database as my drupal installation. There is no need for a different mysql_connect.
The structure is as follows:
code, country
us, United States of America
uk, United Kingdom
jp, Japan
no, Norway
...
I don't want to use the node system for this but just get the country name on my other pages, where the country code is in the node-system. So, it's basically just a lookup.
www.example.com/node/123 has a news article with the country code 'jp' and then I want to show 'Japan' somewhere on the node page.
Additionally I like to see the country name and some more information by calling
Is this possible without any php code, just with drupal supported modules? I'm learning CCK right now but it seems to be node based. Just for clarification, I don't want to import the country database in the node system of drupal, since it gets updated automatically every couple weeks from a running system.
Comments
_
See How to connect to multiple databases within Drupal
Hi WorldFaliz, yes, I read
Hi WorldFaliz,
yes, I read that already. I don't need to connect to multiple databases, just get the data from a database residing on the same mysql-server and same mysql-database as Drupal. I could of course just get the relevant data with a regular mysql_query in php, but I thought there would be a smart module available which does everything for me :-)
_
There's a link at the bottom of the page I linked above that contains all the db functions you can use to do this. Since you really seem to be referring to another table in the same db, which is not what you said above, you just don't need the db_set_active part.
Oops, sorry... Yeah, that's
Oops, sorry... Yeah, that's it. Database Abstraction Layer and Database API. Works like a charm!
The only issue I'm facing now is that's basically impossible to import those fields to the CCK to be able to use the Views module. I guess there is no way around creating the data in Drupal itself to have all advantages. Thus, nodes are created and I can use every other module correctly. Without this step I can just access my data through the Database API, print them out as I done it before (php echo/print) without any advantage filter/grouping etc...
Hmm, I guess I have th rethink the way I planned using Drupal. Initially I planned to leave all my data in the current databases and use Drupal just for viewing everything and have the nice menus. I already see that Drupal is much more than that, if used correctly :-)
_
You actually can expose non drupal data to views, you just need to use the api to tell views about the structure of the data. I believe it's in the advanced help-- if not, it's in the views api documentation.
But yes, you still may wish to rethink this-- drupal provides tons of functionality and optimizations for data that you won't be able to leverage if you keep your data separate.
The genius of drupal is that you can make this choice-- in most systems /cms's it's decided for you. ;-)
Absolutely! I have to say
Absolutely! I have to say that I looked into Wordpress before, liked the tons of Templates, but they are not too difficult to convert to Drupal Themes. I also played with Joomla for a day and I liked the clean admin menu. That was it. When I saw how Drupal developed I was sold... lol. Last time I looked into Drupal it was like 2004/5 when Version 4.6 was current. I decided back than to do everything by hand and here I am again :-) Silly me...
The more I do with Drupal the more I love it! I will look now in the advanced docs. Another possibility I came across is to export my data regulary via xml from my current handcoded system, use the FeedAPI and autocreate/delete/update real Drupal nodes. Also learning aggressively about Taxonomy/Keywords. Drupal is fantastic! Also learning about the whole database structure, inidizes and so on to understand the SQL statements it generates in case I need any optimization.