Creating Admin Tree Menu using Orchard Core Taxonomies

Useful resources:

Basics of taxonomies: https://www.davidhayden.me/blog/taxonomies-in-orchard-core-cms

Demo of Custom Admin Tree Menu:

Prerequisite:

Install the Admin Tree Module by cloning the https://github.com/ThisNetWorks/ThisNetWorks.OrchardCore.AdminTree repository into the following directory:  OrchardCore\src\OrchardCore.Modules and then adding the project under OrcharCore.Modules

  • Add the reference below to \OrchardCore\src\OrchardCore\OrchardCore.Application.Cms.Core.Targets\OrchardCore.Application.Cms.Core.Targets.csproj
    • <ProjectReference Include=”..\..\OrchardCore.Modules\ThisNetWorks.OrchardCore.AdminTree\src\ThisNetworks.OrchardCore.AdminTree.csproj” />

Install ThisNetWorksAdminTheme by cloning the  https://github.com/ThisNetWorks/ThisNetWorks.OrchardCore.Themes repository into the following directory: OrchardCore\src\OrchardCore.Themes and then adding the project under OrcharCore.Themes

  • Add the reference below to OrchardCore\src\OrchardCore\OrchardCore.Application.Cms.Targets\OrchardCore.Application.Cms.Targets.csproj
    • <ProjectReference Include=”..\..\OrchardCore.Themes\ThisNetWorks.OrchardCore.Themes\src\ThisNetWorksAdminTheme\ThisNetworksAdminTheme.csproj” PrivateAssets=”none” />
  • Right now there an issue with the css for this theme not loading correctly https://github.com/ThisNetWorks/ThisNetWorks.OrchardCore.Themes/issues/1
    • Temporary workaround for it is following the steps below:
      • Copy theme.min.css and theme.css into \OrchardCore\src\OrchardCore.Themes\TheAdmin\wwwroot\Styles
      • Edit the file: \OrchardCore\src\OrchardCore.Themes\ThisNetWorks.OrchardCore.Themes\src\ThisNetWorksAdminTheme\Views\Layout.cshtml
        • Change this: <style asp-name=”thisnetworksadmintheme” asp-src=”~/ThisNetWorksAdminTheme/Styles/theme.min.css” debug-src=”~/ThisNetWorksAdminTheme/Styles/theme.css”></style>
        • With this: <style asp-name=”thisnetworksadmintheme” asp-src=”~/TheAdmin/Styles/theme.min.css” debug-src=”~/TheAdmin/Styles/theme.css”></style>

Steps to set up Taxonomy tree

The goal of the following steps is to create Content Item: “Pages” of Content Type: Taxonomy that will have a tree structure as follows:

  1. Enable the Taxonomies module under Configuration > Feature [Under Content Management section]
  2. Go to Content > Content Definition > Content Types to create a new Content Type for the Taxonomy to be created
  3. Make sure the new content type has the Term Container part included
  4. Create the Term Content Types for each page category.
  5. For our example, assuming Main Page has one Content type and Child Page have a different content type, we need to create those two Content Types
  6. Before we can add the Main Pages, create the Content Type for it called “Branch Article”, which must contain a Taxonomy Field
    • Select the Pages taxonomy and the Editor type “Contained”. The editor type change is important to make this Content Type appear under Pages taxonomy’s Term Content Type
  7. Follow the step #6 to create another Content Type called “Leaf Article” that will contain the parts for the Child Pages
  8. Create a new Taxonomy called Pages with term type Category
  9. Add Categories and child categories and organize them in the desired tree structure:
  10. For each category, the creation page will provide options to pick which type of page would be created under that category:
    • Similarly child page can be created with different content type:

Steps to set up Admin Tree

  1. Enable the Admin Menu and Admin Tree Menus modules under Configuration > Feature [Under Content Management section]
  2. Enable ThisNetworks Admin Theme by going to Design > Themes section. Enabling this theme will allow Admin Tree Menus to to appear once set up
  3. Go to Configuration > Admin Menus and click on Add Admin Menu to create a new admin menu:
  4. Click on Edit Nodes to determine what the Admin Menu should contain
  5. Click on Add Node to bring up the following pop up:
  6. Add a Taxonomy Terms Tree using the following settings:
  7. Once done, the terms of Content Item Categories will appear in the admin menu in as a tree as follows:
  8. From the tree, pages can be created as follows:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Powered by WordPress.com.

Up ↑

%d bloggers like this: