2

I am inserting nodes from an external application into Drupal (7.x). I've taken care of the node_revision table and other tables needed by Drupal to see the node. However I have pathauto installed and it does not recognize the node as new as per this link. So my question is, how does Drupal/Pathauto determine if a node is new or not?

Obviously I can't use the $node->is_new property, cause I am doing the inserts from a Zend application. I just want Pathauto to check the Automatic alias checkbox by default.

3
  • 1
    How do you import the nodes, via API or pure SQL?
    – googletorp
    Jan 24 '12 at 12:20
  • Pure SQL. I wasn't aware that there is an API for this. Jan 24 '12 at 12:23
  • btw, you can always run pathauto in batch mode (if you don't want to rewrite your import) ;-)
    – uwe
    Jan 25 '12 at 3:36
4

Pathauto reacts on node save, which doesn't happen when you insert directly via SQL. Pass data from your external application to a custom hook_menu entry, assemble the node from $_GET-data, and run node_save($node), instead of inserting it directly.

Second option, if to enable Services, which allows you to pass data in as json, and have the nodes created that way.

I belive both ways will properly trigger Core hooks, so that pathauto will be called.

1
  • I using node_save but I keep getting the following errors: Warning: Illegal offset type in isset or empty in pathauto_cleanstring() (line 180 of .../sites/all/modules/pathauto/pathauto.inc). Warning: Illegal offset type in pathauto_cleanstring() (line 223 of .../sites/all/modules/pathauto/pathauto.inc). Feb 14 '12 at 21:22
0

When a node is created (using the UI or imported), Drupal sets a datestamp in his database. In the node table, there is a created field. An encoded timestamp is located there.

When you're building a view or some custom code to show the new nodes, Drupal knows which nodes to select because the system simply calculates the difference between today's timestamp and that of the node.

2
  • I don't see how this helps with the pathauto situation?
    – Letharion
    Jan 24 '12 at 12:47
  • 1
    His question is "how does Drupal/Pathauto determine if a node is new or not?" no? So, that's the answer
    – Michiel
    Jan 24 '12 at 13:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.