1

Not sure what the best title for this question was, so hope it makes sense!

I am importing some data from an XML feed into EE via the add on Datagrab.

Its mostly straight forward data, so its pretty simple, but I would like to know if its possible to change the way some of it is imported.

Each entry in the XML feed has a range of "Options"

For example...

...
<option1>1</option1>
<option2>0</option2>
<option3>1</option3>
...

Whereby the value of "1" means yes and "0" means no.

I would like to import these values into a single checkbox field so it would be something like...

Option One [√]
Option Two [ ]
Option Three [√]

Does anyone know if this is possible?

It would save me quite a few custom fields if it is, and will make outputting the data/creating search forms a lot easier!

Thanks.

2
  • Is the range fixed or variable? Commented Apr 17, 2013 at 22:27
  • It'll be fixed. Same number of options for each entry, choice of either 1 or 0.
    – shorn
    Commented Apr 17, 2013 at 22:41

1 Answer 1

1

If you store the actual value of the import as either a 0 or a 1 then can you not place a conditional in your front-end templates to check for either of those values(?):

<input type="checkbox" {if field_name == "1"}checked="checked"{/if} />
5
  • Yep, I had though about that. Front end wise I could just output a list of options that match the value of 1 like so: {if field_name == "1"}<li>Field One</li>{/if} I Was just hoping that it could be imported into a single field for ease. I was also thinking ahead to my search form. I will want users to be able to select the options via my search form (low search) so that it returns entries that have that value matched, and I'm not sure how I can do that via this way.
    – shorn
    Commented Apr 18, 2013 at 10:40
  • What about if you add the multi-select options to the checkbox and map the import to that field? Apparently "By default, checkboxes get the value that matches their label.". Admittedly I've not tried it but it may work if you always no the true (1) and false (0) values are consistent(?)
    – Ian Young
    Commented Apr 18, 2013 at 11:29
  • True and false values will always be 1 or 0. I've just found that thread as well. Not quite sure as can't seem to get head around how it will be pulled in.
    – shorn
    Commented Apr 18, 2013 at 11:33
  • You may want to contact Andrew directly at brandnewbox.co.uk/v8/contact and point him to this question - the guy's a very responsive developer. Commented Apr 18, 2013 at 23:27
  • Yes I'm not entirely sure that would result in the desired outcome but it could just be the case of trial and error as I don't have the latest version of Datagrab to test it on. Other than that as @erwinheiser suggested, you may get a more definitive answer directly from Andrew. I'm sure it must be possible as it seems like a common use case.
    – Ian Young
    Commented Apr 19, 2013 at 8:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.