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
    Commented Jan 24, 2012 at 12:20
  • Pure SQL. I wasn't aware that there is an API for this. Commented Jan 24, 2012 at 12:23
  • btw, you can always run pathauto in batch mode (if you don't want to rewrite your import) ;-)
    – uwe
    Commented Jan 25, 2012 at 3:36

2 Answers 2

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). Commented Feb 14, 2012 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
    Commented Jan 24, 2012 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
    Commented Jan 24, 2012 at 13:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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