2

When I'm programatically creating nodes using the code found here 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).

I have tried providing a default $node->path value, not including a value, setting the value myself using pathauto_cleanstring(), but nothing seems to work. I find it odd that I'm getting the error twice too :s

The solution to this question didn't help either unfortunately :(

Any help on this would be greatly appreciated!

UPDATE:

So, the problem had to do with the data that I was using to create the path. I'm loading an XML file using simplexml_load_file. The value I was using for the node title was a SimpleXMLElement

SimpleXMLElement Object
(
    [0] => Node Title
)

Which needed to be cast as a string before saving it as the nodes title. Thank you all for your help!

  • Not the solution but you should try first node load and check what parameter the pathauto field needed and provide it in that way. – j2r Feb 15 '12 at 6:04
2

Try this:

      $path = 'your value for the path';
  $node->path = array('alias' => $path);
  • Dimitril, I'll try this again, but I'm certain I tried it in a few configurations and the problem was still present. – SomethingOn Feb 15 '12 at 14:00
  • I did this to set the path to the correct alias...not sure if it's necessary but it works: $placeholders[t('[title]')] = pathauto_cleanstring((string)$event->title); $alias = pathauto_create_alias('node', 'insert', $placeholders, array('node'), $node->type); $node->path = array('alias' => $alias); – SomethingOn Feb 16 '12 at 21:00

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.