By xpersonas on
I am trying to add a content type manually through the database. I have a content type defined. And I have a view filtered to read content types of a certain vocabulary.
When I go into the the table through phpMyAdmin for that content type and add a new row at the end with a new unique nid and vid, nothing shows up in my view. I can edit pre-existing entries through the database, but if I add one it will not show up.
Is there something I'm missing? I would appreciate any help.
Comments
Grok the Normalization
You must familiarize yourself with the workings of the Drupal DB before attempting to manipulate it directly - anything short will cause you pain and suffering. This is because Drupal (unlike whatever system you may be accustomed to) does not use a flat 1-for-1 table structure. The Drupal DB is highly normalized. For instance, the act of adding a new node will require you to touch at least 3 tables (node, node_revisions, and sequences), and usually others as well. The act of adding a new content type is even more complex, since it will require the creation of a table for the content type itself.
Until you are intimately familiar with the DB schema, I do not recommend using PHPMyAdmin to add or delete anything. Even then, always make a backup first.
The best way to add nodes is via the API. Look up node_save().
-------------------------------------------
Interactive Worlds and Immersive Obsessions
http://www.asifproductions.com
-------------------------------------------
Interactive Worlds and Immersive Obsessions
http://www.asifproductions.com
Node Import module.
Take a look at the Node Import Module.
http://drupal.org/project/node_import
Thanks.
Thanks. I think this is exactly what I was looking for.
haha
oh yeah ;-) I guess I should have said "Use the API OR find a module that already does what you want to do."
-------------------------------------------
Interactive Worlds and Immersive Obsessions
http://www.asifproductions.com
-------------------------------------------
Interactive Worlds and Immersive Obsessions
http://www.asifproductions.com
Kind of
Ha. Yeah maybe. I get what you were saying. I'm going to end up having content types added to a database via external csv, or similar, files. So I was just trying to figure out how that would work. It looks like the module he pointed me to will do this. I'll eventually have to work back and figure out how it works through the API though.
Thanks for the advice.
It worked for me.
I had the a similar requirement and that module worked great for me.
There's also the import/export API module. It's not being maintained and is looking for an owner.
A great way learn how the API works will be to volunteer :-)
http://drupal.org/project/importexportapi
de nada
Going through the pertinent sections of the API is invaluable as a study exercise. Although it takes time, obviously. But I don't mean to bag on PHPMyAdmin - I use it a lot, and it is a GREAT way to learn what's going on - but it can be dangerous unless you're very careful. If you have SSH/telnet access to the machine, here's the fastest way to do a backup/dump:
TO EXPORT DB TO A FILE:
mysqldump --add-drop-table -p DATABASENAME --user=DATABASEUSER --password=DATABASEPASSWORD > /FULL/PATH/TO/ROOT/MYBACKUP.SQLTO IMPORT DB FROM A FILE:
mysql --user=DATABASEUSER --password=DATABASEPASSWORD DATABASENAME < /FULL/PATH/TO/ROOT/MYBACKUP.SQLReplace the capitalized stuff with your own values.
LVX
TF
-------------------------------------------
Interactive Worlds and Immersive Obsessions
http://www.asifproductions.com
-------------------------------------------
Interactive Worlds and Immersive Obsessions
http://www.asifproductions.com