4
votes

I Followed the following steps in Umbraco to add folder structure in my content nodes.

Step 1

Create a new Document Type called Content Folder.

Go to Settings > Document Types > click on the 3 dots > Create. Give it the name Content Folder. As icon select the folder icon Add a new property Redirect with alias umbracoRedirect with type Content Picker Save changes The built-in property umbracoRedirect is used to redirect one node to another using its id. So for each folder set this property to the first child page.

Step 2

Allow your child node types in this folder.

Go to the structure tab of your Content Folder property Check the child types that you want to allow under this folder Save changes

Step 3

Allow this folder under your root Home node.

Go to the structure tab of your Home root property Check the ContentFoldertype to allow as a child Save changes

Step 4

Add you folder structure and add pages.

Go to your content Add a new folder under your root node of type Content Folder Give it the name HQ Add a new page called A that's allowed under your folder In your HQ set the Redirect property to your first A page Do this for all your folders and pages Save changes and publish

Which worked however I had the following macro in my page which displayed the children of the node I was in. Since I placed these in the root now that I have moved these in a subfolder all lists are 1 level higher than they should be (because the current node is 1 level lower.

In the structure Below I have 2 separate menus one that appears on whether you are on a Chapter or Section Page Within a given chapter that shows a list of all sections in that Chapter. so for Chapter 1 it would show 1.1 and 1.2. The second menu goes on Section and story Pages in that same chapter and displays stories just in that section so if I was on the section 1.1 Page it would show me stories 1.1.1, 1.1.2, and 1.1.3

My Structure Is Like This

    Root
    -Team 1 (Folders)
    --Level 1 (Chapters)
    ---Level 1.1 (Sections)
    ----Level 1.1.1 (Stories)
    ----Level 1.1.2 (Stories)
    ----Level 1.1.3 (Stories)
    ---Level 1.2 (Sections)
    ----Level 1.2.1 (Stories)
    ----Level 1.2.2 (Stories)
    ----Level 1.2.3 (Stories)
    --Level 2
    ---Level 2.1
    ----Level 2.1.1
    --Level 3
    --Level 4
    ---Level 4.1
    ----Level 4.1.1
    -Team 2 Folder
    -Team 3 Folder
<umbraco:Macro  runat="server" language="cshtml"> @inherits umbraco.MacroEngines.DynamicNodeContext

  @*
  Macro to display child pages below the root page of a standard website.
  Also highlights the current active page/section in the navigation with
  the css class "current". 
  *@

  @{ 
  @* Get the root of the website *@
  var root = Model.AncestorOrSelf(1);
  }
  <ul>
    <li>Chapter<br>
      Sections
      <ul>
        @foreach (var page in root.Children.Where("Visible"))
        {
        <li class="@page.IsAncestorOrSelf(Model, "current", "")"> <a href="@page.Url">@page.Name</a> </li>
        }
      </ul>
    </li>
  </ul>
</umbraco:Macro>

I would like to know how I can get my macro working again and refrencing the right nodes.

EDIT

I also have This code to show a second level of nodes

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
<xsl:stylesheet 
    version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:msxml="urn:schemas-microsoft-com:xslt" 
    xmlns:umbraco.library="urn:umbraco.library" xmlns:Examine="urn:Examine" 
    exclude-result-prefixes="msxml umbraco.library Examine ">

<xsl:output method="xml" omit-xml-declaration="yes" />

<xsl:param name="currentPage"/>

<!-- Input the documenttype you want here -->
<xsl:variable name="level" select="2"/>
        <xsl:variable name="startNode" select="$currentPage/ancestor-or-self::*[@level = $level]" />
<xsl:variable name="nodesToShow" select="$startNode/*[@isDoc][not(umbracoNaviHide = 1)]" />

<xsl:template match="/">

<!-- The fun starts here -->
<xsl:if test="$nodesToShow">
    <img src="/media/1133/actheader2.png" alt="Activities in this Section" class="acttitle" />
</xsl:if>
    <ul>
<xsl:for-each select="$currentPage/ancestor-or-self::* [@level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']">
<li>
   <xsl:attribute name="class">
        <xsl:if test="contains(activityextras,'Video')">Video</xsl:if>
        <xsl:if test="contains(activityextras,'Scripted')">Scripted</xsl:if>
        </xsl:attribute>

   <a href="{umbraco.library:NiceUrl(@id)}">
      <xsl:value-of select="@nodeName" />
   </a>
</li>
</xsl:for-each>
</ul>

</xsl:template>

</xsl:stylesheet>
1

1 Answers

1
votes

The part of the code here:

var root = Model.AncestorOrSelf(1);

Gets the page at level 1, which will always be the homePage. If the folders are always at the second level now, you should just be able to change it to:

var root = Model.AncestorOrSelf(2);

That should get you the folder, as long as you're underneath the folder. If you're likely to have nested folders, you'll need to make further changes.