Copied to clipboard

Flag this post as spam?

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


  • yogesh pathak 136 posts 221 karma points
    May 19, 2015 @ 05:54
    yogesh pathak
    0

    Reusing a Content

    my situation is to create a content lets say with an image and text then reuse it into multiple pages

    how can i achive this?

  • Jan Skovgaard 11239 posts 23375 karma points MVP 6x admin c-trib
    May 19, 2015 @ 06:41
    Jan Skovgaard
    0

    Hi Yogesh

    Depending on how the content is structured and what makes sense you can for instance use a "content picker", which will reference the node id and then you will be able to re-use the content from the picked node on another node for instance.

    You can also create a "Data" node in the root of your content section where you can create content elements, which can be referenced on your content pages under your "Home" node using either a content picker or the "Multi node picker", which you can configure to start in the "Data" folder when you set it up in the "Developer -> Datatypes" section.

    Does this make sense?

    /Jan

  • yogesh pathak 136 posts 221 karma points
    May 19, 2015 @ 06:59
    yogesh pathak
    0

    Hey Jan,

    from last three day i am stabing my head with Multinode tree picker , everything works fine but when i pick content using MMTP into any page it shows that cocntent has been picked up , but when i try to preview the page no content being shown at all

  • yogesh pathak 136 posts 221 karma points
    May 19, 2015 @ 07:01
    yogesh pathak
    0

    Do i have to write any code or additional somthing to render the content i have picked up?

  • Urvish 252 posts 770 karma points
    May 19, 2015 @ 08:24
    Urvish
    0

    Hi Yogesh,

    Yes obviously you need to write code to render content you picked.

    You will get the IDs of the picked nodes and you need to use foreach loop to get those contents.

    Hope this will help.

    Regards,

    Urvish Mandaliya

  • yogesh pathak 136 posts 221 karma points
    May 19, 2015 @ 08:44
    yogesh pathak
    0

    Hey Urvish,

    this is what i am using-

    @{
        if (Model.Content.HasValue("CPicker"))
        {
            var bannerList = CurrentPage.CPicker.ToString().Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
            var bannerCollection = Umbraco.Content(bannerList);
            foreach (var item in bannerCollection)
            {
                <p>@item.Name</p>
                var pageConetnt = Umbraco.Content(item.Id);
              contentData=  pageConetnt.GetPropertyValue<string>("grid");
            }
        }
    }

     

    Can you please help how can i get pure content from above pageContent object and render it to any div?

    Sorry for being a noob

  • Urvish 252 posts 770 karma points
    May 19, 2015 @ 09:00
    Urvish
    0

    Hi Yogesh,

    You can have that content inside that foreeach loop.

    As above contentData is you data.

    If you still not able to get content than you can provide me a link of Umbraco , I would dig into it and solve your problem.

    Regards,

    Urvish Mandaliya

  • yogesh pathak 136 posts 221 karma points
    May 19, 2015 @ 09:12
    yogesh pathak
    0

    you lost me on "link of Umbraco" :(

  • Urvish 252 posts 770 karma points
    May 19, 2015 @ 09:14
    Urvish
    0

    I mean to say your website link in which you are running above code.

  • yogesh pathak 136 posts 221 karma points
    May 19, 2015 @ 09:27
    yogesh pathak
    0

    i am doing a POC on Umbraco so i have hosted it under an internal server which can be only accessible if someone will be connected to our VPN (Which i can disclose to anyone :( )

  • Urvish 252 posts 770 karma points
    May 19, 2015 @ 09:33
    Urvish
    0

    Hi Yogesh,

    No problem.

    You can check that what values you are getting in bannerList variable from below code.

    @{
            if (Model.Content.HasValue("CPicker"))
            {
                var bannerList = CurrentPage.CPicker.ToString().Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                var bannerCollection = Umbraco.Content(bannerList);
                foreach (var item in bannerCollection)
                {
                    <p>@item.Name</p>
                    var pageConetnt = Umbraco.Content(item.Id);
                  contentData=  pageConetnt.GetPropertyValue<string>("grid");
                }
            }
        }
    

    If you are getting IDs of the picked node than you can make IpublishedNode object or else Umbraco.Content(item.Id) by this way you can get the content node.

    And than if you have a node than you can easily access the properties of the particular node.

    Let me know if you are not getting it. We can go into dipper.:)

    Regards,

    Urvish Mandaliya

  • yogesh pathak 136 posts 221 karma points
    May 29, 2015 @ 13:30
    yogesh pathak
    0

    Hey Urvish,

    Do you have any example code for rendring content from nodes picked up by Multinode tree picker?

    if yes than can you please show me the example?

    Thanks

    Regards

    Yogesh Pathak

  • Urvish 252 posts 770 karma points
    May 29, 2015 @ 13:49
    Urvish
    0

    Hi Yogesh,

    Please find below code.

    Template :

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
        Layout = null;
    }
    
    <h1> this is simple mntp test </h1>
    
    @{
        if (Model.Content.HasValue("mntp"))
        {
            var mntpValue = Model.Content.GetPropertyValue<string>("mntp");
            var mntpList = mntpValue.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse);
            var mntpCollection = Umbraco.TypedContent(mntpList).Where(x => x != null);
            foreach (var item in mntpCollection)
            {
                <p>@item.Name</p>
            }
        }
    }
    

    Content Page :

    enter image description here

    Output :

    enter image description here

    You can also refer below link.

    https://our.umbraco.org/documentation/Using-Umbraco/Backoffice-Overview/Property-Editors/Built-in-Property-Editors-v7/Multinode-Treepicker

    You can get property values of that selected page in foreach loop.

    It is working fine.

    I don't know what is going wrong in your case. Just check the property alias your have given is correct or not.

    Hope this will help you.

    Regards,

    Urvish Mandaliya

  • yogesh pathak 136 posts 221 karma points
    May 29, 2015 @ 14:03
    yogesh pathak
    0

    This is working absolutely fine , i am getting the name list i have picked up, but i want to render content of these nodes like images,text,grid how can i achive this?

  • Urvish 252 posts 770 karma points
    May 29, 2015 @ 14:12
    Urvish
    1

    Simply you can get property by calling GetProperty method of the node like below.

            foreach (var item in mntpCollection)
            {
                <p>@item.Name</p>
    
                // For Content
                 @item.GetPropertyValue("PropertyAlias")
                // For Grid
                 @item.GetGridHtml("content")
                // For Image
                // You will get image id then you need to get image url using id
                @item.GetPropertyValue("ImagePropertyAlias")
            }
    

    Regards,

    Urvish Mandaliya

  • yogesh pathak 136 posts 221 karma points
    May 29, 2015 @ 14:26
    yogesh pathak
    0

    Thanks this is exctly what i was looking for , you made my day Thanks :)

     

  • Urvish 252 posts 770 karma points
    May 29, 2015 @ 14:31
    Urvish
    0

    Yogesh,

    If you find that answer useful than you can mark answer.

    So that other can get direct solution.

    Regards,

    Urvish Mandaliya

  • yogesh pathak 136 posts 221 karma points
    May 29, 2015 @ 14:33
    yogesh pathak
    0

    Sure :) done

  • Urvish 252 posts 770 karma points
    May 29, 2015 @ 14:36
    Urvish
    0

    :)

Please Sign in or register to post replies

Write your reply to:

Draft