Copied to clipboard

Flag this post as spam?

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


  • Hans 3 posts 23 karma points
    May 26, 2013 @ 21:57
    Hans
    0

    Retreiving x amount of Rich Text Editors in Template

    Hello Umbracians,

    I have spent all afternoon and evening googling and browsing through various docs to find a solution, but couldn't find any. If it's posted somewhere, please accept my apologies for asking the same thing.

    Now, what I wanted to do is use an MVC template in Umbraco to display a variable amount of RTEs on a specific page.

    I can find them by their aliases seperately, but that is not really what I wanted:
    Model.Content.GetPropertyValue("bodyContent1")

    To make it more visible:

    [RTE #1] Alias: "bodyContent1"
    Time flies when you're having fun!

    Doesn't time fly when you're having fun?

    [RTE #2] Alias: "bodyContent2"
    Time crawls when you're unhappy at work!

    Why doesn't the clock go faster, so you can back home to work on your umbraco project?

    Etc.

    How do I loop through the various RTE items?

    Many, many thanks in advance for your replies!

  • Morgan K. 16 posts 57 karma points
    May 29, 2013 @ 22:53
    Morgan K.
    0

    From what I gather on your post, you've created multiple properties in one node (i.e. bodyContent1, bodyContent2, etc).  Is that the case? If so, have you considered making a "container" node, and creating different children under that node with the same property alias of bodyContent?  With that, you would be able to loop through all of the children of that container, calling their bodyContent property.

    Let me know if I reading your post correct.

    -Morgan

    http://fyin.com/umbraco.aspx

  • Hans 3 posts 23 karma points
    May 30, 2013 @ 00:08
    Hans
    0

    Hi Morgan,

    Thank you so much for your reply.
    Thinking about the issue a little bit more, I guess you could say that I would like to do something like 'news' or 'blog' articles and showing this kind of item on the home page in the most right column.

    If I understand your reply correctly, I first need to create a document type, and then create a 'page' (node?) on which I use this document type and give these the same alias.

    Then, I create a razor macro to loop through the various items with the same alias and use this macro on the home page.

    Is this correct?

    Thanks again for your help.

  • Morgan K. 16 posts 57 karma points
    May 30, 2013 @ 00:28
    Morgan K.
    0

    I think you get it.  I would create a 'News Container' document type (alias: NewsContainer) that you would allow to be created as a child of your top level parent node (possibly 'Home'). From there, I would create a doc type of 'News Item' (alias: NewsItem) that would be allowed as a child of the 'News Container'. In that 'News Item', I would put a Title, Date (datePicker), and Body Content.  If your Homepage node is the top level node, the razor would look something like

    @foreach(var item in @CurrentPage.Descendants("NewsItem").OrderBy("Date desc"))

    {

    <h2>@item.Title</h2>

    @item.bodyContent

    }

    If you're going to post these news items on a different area of the site, keep in mind that you have the container to call to (@Library.NodeById(container ID) in a macro, @Umbraco.Content(container ID) in the template), from there call to the children.

  • Hans 3 posts 23 karma points
    May 30, 2013 @ 19:29
    Hans
    0

    Sorry for the belated reply Morgan!

    Your tips helped me a lot. It's now working as I had hoped it would :)

    I will continue to digg deaper and deaper to get to know Umbraco better. Who knows, maybe one day in the far future I might be able to return the favor :P

  • Morgan K. 16 posts 57 karma points
    May 31, 2013 @ 18:05
    Morgan K.
    0

    Happy to hear it's working! The Umbraco cheat sheet has been a resource I've used often when running into a problem with razor, and the video tutorials have been very helpful as well.

    Best of luck in your future development endeavors!

Please Sign in or register to post replies

Write your reply to:

Draft