Copied to clipboard

Flag this post as spam?

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


  • sperr0w 48 posts 81 karma points
    Nov 21, 2009 @ 08:20
    sperr0w
    0

    Add Content items programmaticaly

    Hi!

    Now I try to migrate existing site to umbraco platform. Existing site have a big news section ( about 500 items). All news have this hierarchy:

    newsList->NewsCategory->NewsItem

    I already create all templates and documentTypes I need. Now I need to create in NewsList content item of Umbrraco NewsCategories and NewsItems.

    NewsCategories and NewsItems in existing site is in the two tables of SQL server database. So I need just suggestion how to create documents in content section of umbraco in code.

     

  • sperr0w 48 posts 81 karma points
    Nov 21, 2009 @ 08:40
    sperr0w
    0

    I find static method MakeNew of ContentItem class. Is it right way? But I dont know, how to use it.

  • Richard Soeteman 4049 posts 12922 karma points MVP 2x
    Nov 21, 2009 @ 09:11
    Richard Soeteman
    1

    Hi,

    You could do this yourself using Document.MakeNew  or use the umbImport tool I wrote to import the news items into umbraco.

    Hope it helps you,

    Richard

  • Masood Afzal 176 posts 522 karma points
    Nov 21, 2009 @ 11:06
    Masood Afzal
    1

    As noted by Richard, i would also recommend using umbImportTool. Otherwise Document.MakeNew

                int parentNodeId=1500; // set value
    string docTypeAlias = "NewsItem"

    umbraco.cms.businesslogic.web.Document d = null;
    umbraco.cms.businesslogic.web.DocumentType ddt = null;
    try
    {
    ddt = umbraco.cms.businesslogic.web.DocumentType.GetByAlias(docTypeAlias);
    }
    catch { }

    d = umbraco.cms.businesslogic.web.Document.MakeNew(searchname, ddt, new umbraco.BusinessLogic.User(0), parentNodeId);

    d.getProperty("propertyAlias1").Value = "value1";
    d.getProperty("propertyAlias2").Value = "value2";

    //publish
    d.Publish(new umbraco.BusinessLogic.User(0));
    umbraco.library.UpdateDocumentCache(d.Id);
  • Masood Afzal 176 posts 522 karma points
    Nov 21, 2009 @ 11:07
    Masood Afzal
    0
                d = umbraco.cms.businesslogic.web.Document.MakeNew("document name", ddt, new umbraco.BusinessLogic.User(0), parentNodeId);
  • sperr0w 48 posts 81 karma points
    Nov 22, 2009 @ 08:37
    sperr0w
    0

    Thanks a lot all, I will try and tell here about my results. Also can u tell me, is somewhere in umbraco database saves content section?

    I cnow, that all content is in xml file in data folder, is it xml main storage for content or this file creates on the fly from database?

Please Sign in or register to post replies

Write your reply to:

Draft