Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Rick 92 posts 278 karma points
    Nov 18, 2014 @ 12:32
    Rick
    0

    Multiple values in Field Provider

    Hi,

    I've been through the forum and can't find anything related to this - so apologies if I've missed it and this is a duplicate post!

    I'm importing from an XML file which looks like this:

    <CONTENT>
    <ARTICLE>
    <PAGENAME>News Article 1</PAGENAME>
    <PAGECONTENT>&lt;p&gt;Testing 1&lt;/p&gt;</PAGECONTENT>
    <LANGUAGE>ENGLISH</LANGUAGE>
    </ARTICLE>
    <ARTICLE>
    <PAGENAME>News Article 2</PAGENAME>
    <PAGECONTENT>&lt;p&gt;Testing 2&lt;/p&gt;</PAGECONTENT>
    <LANGUAGE>SPANISH</LANGUAGE>
    </ARTICLE>
    </CONTENT>

    I have a Field Provider which maps against a RTE as I'm importing "PAGECONTENT" from the XML file above.

    However, I'd like my Field Provider to also include the <LANGUAGE> as well as the <PAGECONTENT> node as I would like to apply some logic based on the language before assigning the value to the RTE within Umbraco.

    Can anyone help?

    Many thanks,
    Rick

  • Richard Soeteman 4035 posts 12842 karma points MVP
    Nov 18, 2014 @ 12:40
    Richard Soeteman
    100

    Hi Rick,

    You can solve this in two ways:

    1. Use the RecordImported event (check the manual for an example) there you have the document and all properties from the datasource
    2. Create a custom dataprovider where you cna modify the data in any format you like. Looks like a bit overkill for this solution.

    Hope this helps.

    Best,

    Richard

  • Rick 92 posts 278 karma points
    Nov 18, 2014 @ 12:56
    Rick
    0

    Wow - thank you so much for the quick response Richard!

    I'll have a look at the proposed solutions and report back with my impementation for others.

    Thanks,

    Rick

  • Richard Soeteman 4035 posts 12842 karma points MVP
    Nov 18, 2014 @ 12:59
    Richard Soeteman
    0

    Thanks Rick! and spread the word about fast support :)

  • Rick 92 posts 278 karma points
    Nov 18, 2014 @ 16:22
    Rick
    0

    Hi Richard,

    I used the RecordImported event in the end like you suggested, I then iterate through my xml file and apply logic based on the language node.

    However, in the event signature for RecordImported - the object that comes in is a Document which means I have to then use the obsolete method ...

    Document doc = sender as Document;
    doc.getProperty("basePageBodyContent").Value = htmlValue;
    doc.SaveAndPublish(User.GetUser(0));

    ... to set the value of the RTE.

    Ideally, I'd like to use IContent so that I can use:

    IContent doc = (IContent)sender;

    doc.SetValue("basePageBodyContent", htmlValue);

    Is this possible or am I bound to using Document?

    Thank you so much

    Rick

  • Richard Soeteman 4035 posts 12842 karma points MVP
    Nov 27, 2014 @ 22:16
    Richard Soeteman
    1

    Hi Rick,

    sorry didn't receive a notification on the comment. In 2.5 it's Document. For V3 this will be Icontent.

    Best,

    Richard

  • Rick 92 posts 278 karma points
    Nov 28, 2014 @ 09:55
    Rick
    0

    Hi Richard,

    No problem. Is it safe to install and use CMS Import V3 if the package is still in Beta?

    Thanks,
    Rick

  • Richard Soeteman 4035 posts 12842 karma points MVP
    Nov 29, 2014 @ 07:39
    Richard Soeteman
    0

    Hi Rick

    Yes you can it is supported, if you have definitions created those will be deleted and you need to recreate those ,relation data will be kept in the database so it stills knows which nodes to update etc.

    Hope this helps,

    Richard

Please Sign in or register to post replies

Write your reply to:

Draft