Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By bdanchilla on
This is related to another unanswered post of mine http://drupal.org/node/64520.
Basically what is the way to add a node directly to the database so that it shows up in a forum?
I have inserted/altered data in the node, node_revisions, node_access, forum, and sequences tables.
The node displays properly if I directly access it but is not shown in the table. Why is this?
How do I hook the node to a table? Am I missing changing one of the tables?
Comments
taxonomy?
The forums depend on taxonomy, so I'd think that to plug it directly into the database you also need to put the right entries in the taxonomy tables.
---
Work: BioRAFT
I've updated the term_node table, still nothing!?
do you know of any other table that would need to be updated?
look at forum module
Not off hand, but if you look at the code in forum.module, it should all be layed out there in hook_insert(), etc. A quick perusal sugggests that you're covering all the tables. Do you have any access control module enabled?
---
Work: BioRAFT
tac lite access
I am using taxonomy lite access on one of my sites, and another site has none. The one with taxonomy lite I modified the node_access table to have realm=tac_lite.
Build node object then save?
Is there a specific reason you want to work directly on the database? If not, you'll find it much easier to first build a node object, then save it to the database with a call to node_save. This will automatically call modules that need to save extra information about the node.
--
When your problem is solved, please post a follow-up to the thread you started.
If you are using code ...
If you are using code to add to the database the better way is to construct a node in code and then call node_save(). That way has long as you provide the correct information things get added to the tables correctly and any sequence numbers are also updated. If the details change on what node_save() does your code keeps working.
found a solution
thanks for everyone who helped steer me in the right direction. In the end, I needed to call node_save,
forum_insert and taxonomy_node_save
**And for newer drupal users like myself, you need to call the module functions from within a drupal node. Otherwise, you need to include a bunch of files
node_save calls forum_insert & taxonomy_node_save
node_save should call forum_insert & taxonomy_node_save automatcally, via hook_insert and hook_nodeapi respectively. You may need to fill $node->taxonomy though for that to work.
--
When your problem is solved, please post a follow-up to the thread you started.
what would $node->taxonomy contain?
node_save alone does not work. what values are stored in $node->taxonomy?
Set $node->taxonomy
$node->taxonomy is an array of taxonomy term id's (tids) so you set it like this
where $tid is the term id you want associated with the node. In your case it would also be the forum id.
works great now!
that was the field I was missing to get the nodes to be visible calling only node_save() .
Thanks!