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.
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | import_path.patch | 2.18 KB | robby1066 |
| #2 | import_path.inc_0.txt | 267 bytes | robby1066 |
| import_path.inc.txt | 296 bytes | robby1066 |
Comments
Comment #1
Robrecht Jacques commentedExcept for coding style, it looks ok. I'll add it tomorrow.
Robrecht
Comment #2
robby1066 commentedYeah, it'd been a while since I looked at the coding standards. Here's another version that's a bit more compliant.
Comment #3
Robrecht Jacques commentedNo 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.
Comment #4
Robrecht Jacques commentedFixed in CVS. Thanks!
Comment #5
Robrecht Jacques commentedHmm, 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)andhook_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.
Comment #6
coupet commented+1 for global path prefix or something, possibly.
Comment #7
robby1066 commentedno problem, I'll take a look at it later this afternoon.
Comment #8
robby1066 commentedHere'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.
Comment #9
Robrecht Jacques commentedI'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".
Comment #10
robby1066 commentedyeah, 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.
Comment #11
Robrecht Jacques commentedSetting this as "won't fix". The provided functionality is available in pathauto. Or one can add a global prefix to "path" *before* importing it.