Umbraco Macro refers to the root, but is now broken after migration

I Umbraco has the following steps to add a folder structure to my content sites.

Step 1

Create a new document type called Content Folder.

Go to "Settings"> "Document Types"> click on 3 points> Create. Give this the name of the content folder. As an icon, select the folder icon Add a new Redirect property with an alias of umbracoRedirect with type Content Picker Save changes The built-in property of umbracoRedirect is used to redirect one node to another using its identifier. Therefore, for each folder, set this property to the first child page.

Step 2

Allow child node types in this folder.

Click the tab for the structure of the Content Folder property. Check the child types you want to allow in this folder. Save Changes

Step 3

Allow this folder under the root of the node.

Click the tab for the structure of the Home root property. Check ContentFoldertype to allow Save Changes as a child

Step 4

Add a folder structure and add pages.

Skip to content Add a new folder under your root node of type Content Folder. Give her the name HQ. Add a new page called A, which is allowed under your folder. In your HQ for the Redirect first A page property, do this for all of your folders and pages. Save changes and publish

, , , node, . , , 1 , ( node 1 .

2 , , , . 1 1.1 1.2. , , 1.1, 1.1.1, 1.1.2 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>

, .

,

<?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>
+4
1

:

var root = Model.AncestorOrSelf(1);

1, . , :

var root = Model.AncestorOrSelf(2);

, . , .

+1

Source: https://habr.com/ru/post/1599405/


All Articles