I am using Asp.net MVC SiteMap Provider to manage the sitemap of my website.
Structure of Application:
It is a small application where I have an area called "Admin"
SiteMap
<mvcSiteMapNode title="LET'S GO" controller="Home" action="Index">
<mvcSiteMapNode title="FESTAS" controller="Festas" action="Index">
<mvcSiteMapNode title="INFANTIL" controller="Festas" action="Infantil" />
<mvcSiteMapNode title="ADULTO" controller="Festas" action="Adulto" />
</mvcSiteMapNode>
<mvcSiteMapNode title="ORÇAMENTO" controller="Home" action="Index" />
<mvcSiteMapNode title="CONTATO" controller="Home" action="Contato"/>
<mvcSiteMapNode title="ADMINISTRAÇÃO" area="Admin" controller="Home" action="Index">
<mvcSiteMapNode title="FESTAS" area="Admin" controller="Festas" action="Index" />
<mvcSiteMapNode title="SUBSIDIÁRIAS" area="Admin" controller="Subsidiarias" action="Index" />
</mvcSiteMapNode>
</mvcSiteMapNode>
Problem
To display the main menu, use the following command:
#Html.MvcSiteMap().Menu()
This is the first problem, all nodes are displayed.
I would like to display only the nodes roots ("INFANTIL" and "ADULTO" for example will not be displayed)
The nodes of the Admin area can not be displayed. They only appear on another view.
How can I accomplish these tasks?
Question
How can I generate a sitemap only a specific node?
Example: I want to generate the sitemap only child node of "ADMINISTRAÇÃO"
Thanks to everyone!!
1) I would like to display only the nodes roots ("INFANTIL" and "ADULTO" for example will not be displayed)
#Html.MvcSiteMap().Menu(1, 1)
2) The nodes of the Admin area can not be displayed. They only appear on another view.
May be you should use roles attribute.
Creating a first sitemap
How can I generate a sitemap only a specific node?
Try to use one of the overloaded method
public static System.Web.Mvc.MvcHtmlString Menu(this MvcSiteMapProvider.Web.Html.MvcSiteMapHtmlHelper helper, System.Web.SiteMapNode startingNode, bool startingNodeInChildLevel, bool showStartingNode, int maxDepth)
I know this question is bit outdated, but for future use:
this can easily be done by decorating the Actions (or Controller) with access permissions.
I assume that not everybody can access the administrative part (only the accredited). So you could create eg an Administrative Role and decorate with a FilterAttribute the Actions (or Controller): eg
[Authorize(Roles = "Administrator")]
public ActionResult Index()
{ .... }
Once the user has identified herself as an Administrator the sitemap entry for the Index Action will be shown.
Related
I have two user types-
-Admin
-Visitor
If the user type is "Visitor" then the Sub1 node will not be there in the menu.But the below code doesn't work to hide/remove the specific node.
My Sitemap looks like:
<mvcSiteMapNode title="Home" controller="Home" action="Index">
<mvcSiteMapNode title="Site Map Test" controller="SitemapTest"action="Index" key="sitemaptestnode">
<mvcSiteMapNode title="Sub1" controller="SitemapTest" action="Sub1" key="Childsitemaptestnode1" visibility ="false"/>
<mvcSiteMapNode title="Sub2" controller="SitemapTest" action="Sub2" key="Childsitemaptestnode2"/>
<mvcSiteMapNode title="Sub3" controller="SitemapTest" action="Sub3" />
</mvcSiteMapNode>
</mvcSiteMapNode>
From the Layout.cshtml I have called
#Html.Action(“RenderMenu”,”Menu”);
Public void RenderMenu(){
var node = MvcSiteMapProvider.SiteMaps.Current.FindSiteMapNodeFromKey("Childsitemaptestnode1");
If (node.title =="Sub1"){
//Function to get the user type from database
String UserType=GetUserTypes();
If(UserType=="Visitor"){
//Hide Sub1 node from Menu
node.Attributes["visibility"]="!*"; }
}}
The most common way to handle this is to use group-based security and use the AuthorizeAttribute.
However, in this simple scenario you don't even really need groups. Adding the AuthorizeAttribute to your action method will automatically deny any users that are not logged in.
[Authorize]
public ActionResult Sub1()
{
return View();
}
This assumes you have setup a security framework that implements IPrincipal and IIdentity (of which ASP.NET Identity and Membership both do). You can get the basic framework for one of these options by using one of the default templates created by Visual Studio and copying over the relevant bits (AccountController, ManageController, related views, and related startup code) into your project.
All that would be required in MvcSiteMapProvider would be to enable security trimming.
Internal DI (web.config)
<appSettings>
<add key="MvcSiteMapProvider_SecurityTrimmingEnabled" value="true"/>
</appSettings>
External DI (MvcSiteMapProvider Module)
bool securityTrimmingEnabled = true; // Near the top of the module
That will make the nodes automatically hide when the user doesn't have access and AuthorizeAttribute will actually secure the URL so the user can't navigate there directly.
Changing visibility of a link doesn't secure anything, but if that is all you want, you should refer to the visibility provider section of the documentation.
As per my understanding, inventory of SKUs should be maintainted by business users. But, I don't see option(UI) for that in BCC. Is my understand wrong? If not, what is the strategy Oracle/ATG recommending business users to maintain inventory management? Why no UI given for business users for the same? what is the reason behind it?
But default inventory administration is done via dyn/admin.
The reason for this even i donno.ACC and dyn/admin are legacy modules of ATG.So may be when BCC came in picture they just left inventory as is.If u see even ACC is capable of doing almost all things what BCC does.Infact it also additionally configures scenarios for ATG.So all i could say there may be a reason behind all this.Infact they(Oracle) are the market leaders.
In http://hostname:8080/dyn/admin go to Commerce Administration->Inventory Administration.or just http://hostname:8080/dyn/admin/atg/commerce/admin/inventory/index.jhtml
assuming 8080 is publishing port.You can also view inventory in production server also.
This page allows an administrator to view the results of the inventory query operations, to manipulate the various properties of each item, and to notify the system of inventory updates. Out-of-the-box, the interface allows the administrator to set, increase, or decrease the stockLevel, backorderLevel, and preorderLevel of any item in the inventory. This page also allows the administrator to set the stockThreshold, backorderThreshold, preorderThreshold, availabilityStatus, and availabilityDate for each item. is configured through The properties files of the servlet beans described below configure the updated inventory.
But to be honest we can override this behaviour by doing the following.
you can add the Invenory repository as a separate tab in bcc as follows by doing the following changes.
config/atg/remote/controlcenter/service/ApplicationConfigurationManager.properties (OOTB)
applicationFiles+=/com/remote/controlcenter/service/inventory.xml
config/com/remote/controlcenter/service/inventory.xml (Custom)
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE application-configuration
PUBLIC "-//Art Technology Group, Inc.//DTD BCC Application Configuration //EN"
"http://www.atg.com/dtds/application-configuration/application-configuration_1.0.dtd">
<applications>
<application id="editInventory">
<resource-bundle>com.webui.WebAppResources</resource-bundle>
<display-name-resource>editInventory.displayName</display-name-resource>
<destination-page>
<url>/AssetManager/assetManager.jsp</url>
<query-parameter key="project" value="-1" />
<query-parameter key="activity" value="editInventory" />
</destination-page>
<acl>Profile$role$epubAdmin:read;Profile$role$epubSuperAdmin:read;Profile$role$epubManager:read;Profile$role$epubUser:read</acl>
<initializer>
</initializer>
<sort-priority>30</sort-priority>
<category>yourProjectExtras</category>
</application>
</applications>
config/atg/web/assetmanager/configuration/taskConfiguration.xm (OOTB)
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE task-configuration
PUBLIC "-//Art Technology Group, Inc.//DTD Asset Manager Task Configuration//EN"
'http://www.atg.com/dtds/web/assetmanager/taskConfiguration_1.0.dtd'>
<task-configuration>
<!-- Define an activity for editing the inventory repository -->
<activity id="editInventory" inherit-from="assetManager.defaultEdit">
<activity-name>editInventory</activity-name>
<!-- Configure the buttons on the toolbar -->
<operations>
<operation>create</operation>
<operation>delete</operation>
</operations>
<!-- Define tabs for the left pane -->
<tabs>
<tab-order>
<tab-id>browse</tab-id>
<tab-id>search</tab-id>
</tab-order>
<initial-tab>browse</initial-tab>
<!-- Configure the Browse tab with a list view of inventory items -->
<tab id="browse">
<display-name-resource>assetManager.tab.browse</display-name-resource>
<page>/browse/browseTab.jsp</page>
<views>
<view-order>
<view-id>editInventory.inventory</view-id>
</view-order>
<initial-view>editInventory.inventory</initial-view>
<view id="editInventory.inventory">
<resource-bundle>com.webui.WebAppResources</resource-bundle>
<display-name-resource>editInventory.browseTab.view.inventory</display-name-resource>
<configuration>/com/web/assetmanager/InventoryViewConfiguration</configuration>
<page>/browse/list.jsp</page>
</view>
</views>
</tab>
<!-- Configure the Search tab to allow searching for inventory items -->
<tab id="search">
<display-name-resource>assetManager.tab.search</display-name-resource>
<page>/search/searchTab.jsp</page>
<views>
<initial-view>form</initial-view>
<view id="form">
<page>/search/searchForm.jsp</page>
<item-types>
<item-type>/atg/commerce/inventory/InventoryRepository:inventory</item-type>
</item-types>
</view>
<view id="results">
<page>/search/searchResults.jsp</page>
</view>
</views>
</tab>
</tabs>
</activity>
</task-configuration>
config/com/web/assetmanager/InventoryViewConfiguration.properties (Custom)
$class=atg.web.assetmanager.configuration.FilterableBrowseListViewConfiguration
# The path to the repository from which to draw the items
repositoryPath=/atg/commerce/inventory/InventoryRepository
# The type of items to display
assetTypeName=inventory
# Types the user is allowed to create in this view
createableTypesList=inventory
# Number of items to show per page
itemsPerPage=50
/config/atg/bizui/activity/ActivityManager.properties (OOTB)
activitySources+=/com/activity/ActivitySource
config/com/activity/ActivitySource.properties (Custom)
$class=atg.bizui.activity.PortalActivitySource
# The name and description for the entry that appears on the left side of the home page.
activitySourceResourceBundle=com.webui.WebAppResources
activitySourceNameResource=activitySourceName
activitySourceDescriptionResource=activitySourceDescription
# Generic activity definitions
genericActivityDefinitionFiles=/com/activity/genericActivities.xml
genericActivityFileModificationInterval=every 300 seconds
securityConfiguration=/atg/dynamo/security/SecurityConfiguration
XMLToolsFactory=/atg/dynamo/service/xml/XMLToolsFactory
scheduler=/atg/dynamo/service/Scheduler
#defaultCreateWorkflowURL=/atg/bcc/process
defaultCreateWorkflowURL=/atg/bcc/process?successURL=/AssetManager/assetManager.jsp
# Default URL for the main project page.
defaultProcessURL^=/atg/bizui/activity/PublishingActivitySource.defaultProcessURL
# Default URL for the workflow task page. All tasks use the AssetManager UI.
defaultTaskURL=/AssetManager/assetManager.jsp
fallbackPriority=2
/config/com/activity/genericActivities.xml (Custom)
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE gsa-template
PUBLIC "-//Art Technology Group, Inc.//DTD General SQL Adapter//EN"
"http://www.atg.com/dtds/activitymanager/activitymanager_1.0.dtd">
<generic-activities>
<!-- Add a link named "Edit Inventory" -->
<activity>
<id>editInventory</id>
<resource-bundle>com.webui.WebAppResources</resource-bundle>
<display-name-resource>editInventory.displayName</display-name-resource>
<description-resource>editInventory.description</description-resource>
<destination-page>
<!-- This link takes the user to the AssetManager UI -->
<url>/AssetManager/assetManager.jsp</url>
<!-- The clear-context flag clears any active Content Administration project references out of the user's session. -->
<clear-context>true</clear-context>
<!-- The ACL is optional. This ACL limits the visibility of this link to people with any of the epub roles. -->
<acl>Profile$role$epubAdmin:read;Profile$role$epubSuperAdmin:read;Profile$role$epubManager:read;Profile$role$epubUser:read</acl>
</destination-page>
</activity>
</generic-activities>
Restart the publishing server if it is already running.
source:
https://community.oracle.com/thread/2354883
I am using MVC SiteMap from codeplex , I've set sitemap to this
<mvcSiteMapNode title="LEADS" controller="Leads" action="DetailsLeads" Url="/Leads/DetailsLeads" roles="TEST">
<mvcSiteMapNode title="LEADS1" controller="Leads" action="ScheduleMettingLeads" Url="/Leads/ScheduleMettingLeads" roles="TEST"/>
<mvcSiteMapNode title="LEADS2" controller="Leads" action="ServiceAppealLeads" Url="/Leads/ServiceAppealLeads" roles="TEST"/>
</mvcSiteMapNode>
When I am setting securityTrimmingEnabled="true" , I am getting following Error:
Ambiguous controller. Found multiple controller types for LeadsController. Consider narrowing the places to search by adding you controller namespaces to ControllerBuilder.Current.DefaultNamespaces.
Area setup is quite tricky. Please see this issue for an explanation of how to set up areas with MvcSiteMapProvider.
https://github.com/maartenba/MvcSiteMapProvider/issues/78?source=cc#issuecomment-20918916
I have a web site using MvcSiteMapProvider for the main navigation. I have run into a scenario that I'm unable to figure out.
My site has the following navigation:
The site map looks like:
<?xml version="1.0" encoding="utf-8" ?>
<mvcSiteMap xmlns="http://mvcsitemap.codeplex.com/schemas/MvcSiteMap-File-3.0" enableLocalization="true">
<mvcSiteMapNode title="Look Up" controller="Lookup" action="Index">
<mvcSiteMapNode title="PackingList" controller="PackingList" action="Index">
<mvcSiteMapNode title="Configuration" controller="Configuration" action="Printers">
<mvcSiteMapNode title="Printers" controller="Configuration" action="Printers" />
<mvcSiteMapNode title="Quick List" controller="Configuration" action="QuickList" />
</mvcSiteMapNode>
</mvcSiteMapNode>
</mvcSiteMap>
I have not been able to figure out how to properly leverage the site map for the side tab navigation reliably. I also need to have the Configuration tab remain selected as well as the active side tab.
When two nodes have the same controller and action name, the SiteMapProvider cannot determine which node is active, and it always chooses the first matching node, in this case 'Configuration'.
The only way to make both nodes selected is:
Use a different action of the printers menu
Changed the display template to indicate the nodes in the current path with a CSS class or a like
This has been driving me crazy for the last couple of hours. I am using the MVC Sitemap Provider to add breadcrumb functionality.
Let me go through the steps of what I have done so I can make this as clear as possible
Downloaded the resource from Nuget
I then have the following in my sitemap
<?xml version="1.0" encoding="utf-8" ?>
<mvcSiteMapNode title="Vehicles" controller="Vehicles" area="Vehicles" action="Index">
<mvcSiteMapNode title="VehicleName" controller="Vehicles" area="Vehicles" action="Showroom" >
<mvcSiteMapNode title="Overview" area="Vehicles" controller="Vehicles" action="Overview" />
</mvcSiteMapNode>
</mvcSiteMapNode>
And I have this in my view
#Html.MvcSiteMap().SiteMapPath()
My first questions is: How can I have in replace "VehicleName" for action Showroom, with my actual VehicleName?
My actual problem is: My id is not persisted through to the parent. For example my url will be localhost:44357/Vehicles/Overview/Soul/1, and the parent url will be localhost:44357/Vehicles/Showroom, instead of localhost:44357/Vehicles/Showroom/Soul/1. The vehiclename in the url is optional, so the url can just be localhost:44357/Vehicles/Showroom/1.
I hope this makes sense
Thanks for your help.
For questions 1: Set the VehicleName on the parent node. For example: ((MvcSiteMapNode)SiteMap.CurrentNode.Parent).RouteValues.Add("VehicleName", "SomeVehicle");. A good option may also be to use dynamic node providers for creating your sitemap structure.
For question 2: [SiteMapPreserveRouteData] should do the trick