Jump to content

import pages by csv - how to create tags in page fields from this?


Recommended Posts

Hi everyone,

i've build the recommended setup for processwire to work with tags, which means i have a page tree "Tags" and this page tree hold several title-only pages, each represents a tag. 

for the gallery items i like to tag, i've build a template with an categories field of the type "page", this template will be used by every item to hold the tags. the field is "free tagging" field, so it would create the tag-pages autmaticly.

now i need to import a csv file and this is where i have a problem:

when i'm using "the import pages by csv" module, i am not able to select the category field as csv target.

the tags column of my csv holds comma separated words as tag, so the schema looks like this:

Some title       |   birds, unicorns, kittens
Another title    |   hearts, stars, pie

so i need to be able to select a page reference field as target for the TAGS column of the csv, and for every comma separated word i need to create a page tag automaticly and add this tag to the gallery item

i hope it's understandable what i like to do, otherwise feel free to let me explain it again 

Link to comment
Share on other sites

This can be done since this update: http://processwire.com/blog/posts/processwire-core-updates-2.5.16/#set-page-references-from-title-string So you need to run at least version 2.5.16

Thank you for the hint.awesome stuff! But It seems the missing importPagesCSV is still needed:

So I updated the ImportPagesCSV module to support import of Page fields (to be posted soon)

Any news about this Ryan? :)
Link to comment
Share on other sites

Funny you should post this I just shot off an email today to the maintainer of the website I built. So yes, you absolutely can import into a pagefield using the csv plugin. A page field is pretty much just the page path. So try this out, if you need to do tags using a pagefield it will look like this.

image   another_field      tag_field       tag_field     tag_field   tag_field
img.jpg  data                    tag path       tag path     tag path     tag path

if your tags are all in one place like siteroot/tags then your path will basically just be    /tags/tagname. Do this for every tag on one line. If you put your tags on different lines then they will just override the one before. 

**Edit I didn't read that you didnt have the tags created yet. You will need to create a csv of just tags first and make those before you try to link them, but that is nothing that 5 min in excel or your favorite spreadsheet program can't solve. 

Link to comment
Share on other sites

Adding the page references via the csv module was/is allready possible:

https://processwire.com/talk/topic/383-module-import-pages-from-csv-file/page-4#entry21476. And now apparently also via titles, as LostKobrkai points out.

But i think you also want to create the tag pages (under a different parent) on the fly with this module. I'm not sure but i don't think this is possible.

A solution would be to grab all the unique tags from your csv and import the tags seperately. Ah, MuchDev already said it.

After that import the gallery items with the page (tag) references like above link.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...