Copied to clipboard

Flag this post as spam?

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


  • Kyle Skrinak 272 posts 327 karma points
    Aug 03, 2012 @ 04:06
    Kyle Skrinak
    0

    A veiw of nodes within a node

    I'm thinking out loud about content modeling for a hot project I'm working on and would love some ideas. Yes, I've done my google homework but I'd love to hear from a veteran or two on the "umbraco" way.

    I have two layouts that are comprised of multiple elements that share display properties but are unique by way of content:

    • Inline call out box:
      • Title,
      • Positive/Negative (+/-) attribution,
      • picture and
      • description text.
    • Colorbox callouts:
      • Title,
      • description text.
      • Additional function of calling Colorbox to emphasis the clicked object in Colorbox fashion

    In Drupal, I would create a unique node type with these fields/attributes and then create a view that aggregates these elements into a templated block that displays within a specified page, as per the db query's definition.

    I presume the umbraco way to to create doctypes with these attributes and necessary attendant templates. However, next is placing this "non-URL subcontent" within the content layout, i.e., a node that renders to a URL. How would I call the children nodes of a specific branch for rendering? What if I only want to call one specifically, since some are arbitrarily required.

    I apprecate any suggestions or pointers.

  • Kyle Skrinak 272 posts 327 karma points
    Aug 03, 2012 @ 04:25
    Kyle Skrinak
    0

    Off topic and for the record, I would dearly love to correct the spelling of "view" in my title, but the forum won't allow it.

    If I "edit" this post, I get:

    Error parsing XSLT file: \xslt\forum-commentsList.xslt

    If I try to delete this post (and start over) after clicking I get a "post deleted" notice, but, alas, it's still here.

  • Damiaan 442 posts 1301 karma points MVP 6x c-trib
    Aug 03, 2012 @ 17:07
    Damiaan
    1

    Concerning the XSLT error messages on the forum: some day they will be gone completely.

    What your document structure concerns.  There is no "best" way to do this.  But everything is possible.

    You can do this the same as in Drupal.  Create a specific document type, then create a macro which works against the childnodes.  Put the macro on your master and you're good to go.

    If the properties are really tied to the document, just create a new Tab with the properties on the document without creating a separe document type.  Creating a document type implies that you can create multiple child nodes.  (not sure if that is the  case).

    You can't open a URL of a node that has no template.  But you can loop these nodes without any problem from anywhere in your website.
    A few things depend on how you can reference them and how to filter them.  You can use XSLT/XPATH.  If you want to use RAZOR, that is no problem at all.  You can even loop every node and perform the most advanced manual if necaissary.

    a razor example might be:

    @foreach(var node in Model.AncestorOrSelf(1).Descendants("MyDocType")) {
    if(some condition is true on the node) {
        continue;
      }
      // do funky stuff
    }

    It are a lot of questions and a few answers.  If you need more information, don't hesitate to ask one question at a time  :-)

  • Kyle Skrinak 272 posts 327 karma points
    Aug 05, 2012 @ 03:07
    Kyle Skrinak
    0

    I've created the docType, populated the data, and now I want to have render out the content via a macro. I'd like to use the masterpage I created for the docType, but I'm failing to find how to do this in a macro, razor or XSLT.

  • Kyle Skrinak 272 posts 327 karma points
    Aug 05, 2012 @ 12:59
    Kyle Skrinak
    0

    FYI. I've recreated the masterpage as a razor file. I'm including the code here, hopefully it will help whoever is looking to construct an img tag with all attributes in a razor macro.

    @{
      var rating = "<span class=\"orange\">+</span>";
      
      if (@Model.Id == 1081)
      {
        <div id="case-study-block">
          @foreach (var item in @Model.NodeById(1097).Children)
          {
          if (item.positiveNegativeStory == "-")
          {
          rating = "<span class=\"red\">-</span>";
          }
          <div class="cs clearfix">
      <h1>@rating</h1>
      <h2><span class="circle">@item.positiveNegativeStory</span> <span>fission:</span> @item.pageName</h2>
      <div class="cs-content">
        <div class="cs-image"><img src="@Library.MediaById(@item.image).UmbracoFile"
          width="@Library.MediaById(@item.image).UmbracoWidth" height="@Library.MediaById(@item.image).UmbracoHeight" alt="@item.pageName logo" />
        </div>
        <p class="cs-desc">@Html.Raw(item.description)</p>
      </div>
          </div>
          }
        </div>
      }
    }
Please Sign in or register to post replies

Write your reply to:

Draft