Hi there, not quite sure if I posted this in the right place. Feel free to recategorize if appropriate.

I just created an include file that allows a user to specify a path alias in the import csv. Nothing fancy, just maps a field to the node->path object.

Seeing as how I looked around and didn't find an existing version, I thought I'd offer it up as a contribution if anyone was interested. I'd also be willing to work on this and add some extra features in if there was a desire for it. I can see potentially a global path prefix or something, possibly.

Apologies if this already exists somewhere and I somehow missed it.

Comments

Robrecht Jacques’s picture

Except for coding style, it looks ok. I'll add it tomorrow.

Robrecht

robby1066’s picture

StatusFileSize
new267 bytes

Yeah, it'd been a while since I looked at the coding standards. Here's another version that's a bit more compliant.

Robrecht Jacques’s picture

Status: Active » Needs work

No need to test whether path module is enabled. This is done in node_import.module. I'll make the changes myself and commit later today.

Robrecht Jacques’s picture

Status: Needs work » Fixed

Fixed in CVS. Thanks!

Robrecht Jacques’s picture

I'd also be willing to work on this and add some extra features in if there was a desire for it. I can see potentially a global path prefix or something, possibly.

Hmm, just read this sentence more carefully. I think I might be useful to have such a feature. If you want to program it, I have no problem adding it. This will probably mean implementing hook_node_import_global($type) and hook_node_import_prepare($node, $preview), both of which would be trivial I think.

So if you want to do this, just open a new issue with a patch.

coupet’s picture

+1 for global path prefix or something, possibly.

robby1066’s picture

I think I might be useful to have such a feature.

no problem, I'll take a look at it later this afternoon.

robby1066’s picture

StatusFileSize
new2.18 KB

Here's a patch to the import_path.inc file that allows for global path alias functionality. Users can define a "Global path template" that will be used to create a path alias for their node. They can use the placeholder "%title%" anywhere in their path template and it will be replaced with the node's title. If they don't use the placeholder, the title will be tacked on to the end of the template, creating a unique path.

I had originally hoped to have a placeholder for every imported field, but wasn't sure how to enforce unique paths, so I just stuck with the title.

Robrecht Jacques’s picture

Status: Fixed » Needs review

I'll look at it later. Looks ok. Placeholders are nice (maybe more?), on the other hand, this is the kind of thing that is done "automatically" when you install pathauto (or was it autopath).

Setting status to "patch".

robby1066’s picture

yeah, after getting into it a little bit I started to realize that if someone had path auto installed, they'd pretty much already have this functionality and a lot more. So maybe it's redundant unless you want to account for people that don't have pathauto installed? On the one hand it's nice to have all the options in front of you during the import process, but on the other it's potentially a bit of duplicated functionality.

Robrecht Jacques’s picture

Status: Needs review » Closed (won't fix)

Setting this as "won't fix". The provided functionality is available in pathauto. Or one can add a global prefix to "path" *before* importing it.