Using a custom module to import nodes, I am finding that while aliases are made on node_save (from pathauto) the node path itself is not working. Using Content: Link field in a View results in node/(node id) instead of its alias.
Here is the code I am using to create nodes:
$node = new stdClass();
$node->type = 'article';
node_object_prepare($nod开发者_Python百科e);
$node->language = LANGUAGE_NONE;
$node->title = substr(strip_tags($clean_title), 0, 20) . '...';
$node->body[$node->language][0]['value'] = $clean_body;
$node->status = 1;
$node->archive = 0;
$node->uid = 1;
node_save($node);
How can I connect the node with the url_alias? I can see them being created in the url_alias table.
Note: I added $node->language = LANGUAGE_NONE;
just after posting this and this seems to have corrected my issue. Easy to miss!
精彩评论