Add custom variables in magento 2 to use in REST API - rest

I am using some data in my web site like social links, contact address, contact phone, slider banners, I can use them as html in blocks or contact pages. But I am facing a problem, How to call them as REST API. I Already uses Magento2 API:
/V1/cmsBlock/:blockId
/V1/cmsPage/:pageId
But the respobse is html and it is so bad. any help?

For the data like social links, contact numbers etc I suggest you to add this as text in the configuration, to do so you can create a module that has the following structure:
app/code/Jsparo/Customapi/registration.php
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Jsparo_Customapi',
__DIR__
);
app/code/Jsparo/Customapi/etc/module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
<module name="Jsparo_Customapi" setup_version="1.0.0">
</module>
</config>
app/code/Jsparo/Customapi/etc/adminhtml/system.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<tab id="jsparo" translate="label" sortOrder="1100">
<label>Jsparo</label>
</tab>
<section id="jsparo_social" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Social</label>
<tab>jsparo</tab>
<resource>Jsparo_Social::config</resource>
<group id="facebook" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Facebook</label>
<field id="url" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Facebook Url</label>
</field>
</group>
</section>
</system>
</config>
app/code/Jsparo/Customapi/etc/webapi.xml
<?xml version="1.0"?>
<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Webapi:etc/webapi.xsd">
<route url="/V1/jsparo/facebook" method="GET">
<service class="Jsparo\Customapi\Api\FacebookInterface" method="getUrl"/>
<resources>
<resource ref="anonymous"/>
</resources>
</route>
</routes>
app/code/Jsparo/Customapi/etc/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Jsparo\Customapi\Api\FacebookInterface" type="Jsparo\Customapi\Model\Facebook"/>
</config>
app/code/Jsparo/Customapi/Api/FacebookInterface.php
<?php
namespace Jsparo\Customapi\Api;
interface FacebookInterface {
/**
* #return string $url
*/
public function getUrl();
}
app/code/Jsparo/Customapi/Helper/Data.php
<?php
namespace Jsparo\Customapi\Helper;
use Magento\Framework\App\Helper\AbstractHelper;
class Data extends AbstractHelper {
const prefix = 'jsparo_social/';
private function moduleConfig($key) {
return $this->scopeConfig->getValue(self::prefix . $key);
}
public function getFacebookUrl() {
return $this->moduleConfig('facebook/url');
}
}
app/code/Jsparo/Customapi/Model/Facebook.php
<?php
namespace Jsparo\Customapi\Model;
use Jsparo\Customapi\Helper\Data;
class Facebook implements FacebookInterface {
private $helper;
public function __construct(
Data $helper
) {
$this->helper = $helper;
}
public function getUrl() {
return $this->helper->getFacebookUrl();
}
}
You might have to do some adjustments and add all the fields / api endpoints that you need to it.
You can add also Caching to your API by using the Magento\Framework\App\CacheInterface to avoid having to perform certain computations.
Notice that I created the endpoint with the anonymous role, so that it is not protected.
EDIT: I created a github repository where you can see the full source and edited the couple typos that were above. I assume that this module source code gets added in app/code/Jsparo/Customapi.

Related

Dynamic Servicefabric Settings and Overrides

Is there a way to not tell the service about the settings at all and just provide them at the application level?
I am still unhappy with how servicefabric configuration seems to work.
Near as I can tell I have to specify in the service’s settings.xml all of the possible configuration values. Then I can override those in the application’s ApplicationParameters. Per documentation this looks like it holds true for environment variables also.
The complication that creates is that our configuration is used to hydrate options in many cases with arrays.
For example consider the json:
{
"AuthorizationOptions": {
"Policies": [
{
"Name": "User",
"Groups": [ "Domain Users" ]
}
]
}
}
There are 2 arrays; that are necessary and useful. To express this in the service fabric configuration it translates to:
<Section Name="AuthorizationOptions">
<Parameter Name="Policies:0:Name" Value="User"/>
<Parameter Name="Policies:0:Groups:0" Value="Domain Users"/>
</Section>
While the translation is not pleasant in comparison to the structured object it is completely usable.
However, If I don’t specify the section and parameters in the service, I can’t seem to override them in the application. So in this case I would have to define the exact number of policies and groups per policy in the service and the application could modify the policy name, or the group values, but not the number of policies total or number of groups total.
Is there a way to not tell the service about the settings at all and just provide them at the application level?
If not what alternatives exist to make the service reusable across applications that I may want to use to provide this type of dynamic configuration differently?
The last part of the puzzle that may assist in answering this question is I am using some pre-release code to translate the service fabric settings into Microsoft.Extensions.Configuration.IConfiguration. However, that is just taking the settings it finds; it isn't the cause of the override issue I am running into.
Example Service Settings.xml:
<?xml version="1.0" encoding="utf-8" ?>
<Settings xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/2011/01/fabric">
<Section Name="AuthorizationOptions">
<!-- I should not have to provide these at the application level!
However, it fails to deploy if I don't. -->
<Parameter Name="Policies:0:Name" Value="User"/>
<Parameter Name="Policies:0:Groups:0" Value="Domain Users"/>
</Section>
</Settings>
Example Application ApplicationManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<ApplicationManifest xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ApplicationTypeName="ServiceFabric.ExampleType" ApplicationTypeVersion="1.0.0" xmlns="http://schemas.microsoft.com/2011/01/fabric">
<Parameters>
<Parameter Name="Service.Example_ASPNETCORE_ENVIRONMENT" DefaultValue="" />
<Parameter Name="Service.Example_InstanceCount" DefaultValue="-1" />
<Parameter Name="Service.Example_AuthorizationOptions_Policies_0_Name" DefaultValue="Users" />
<Parameter Name="Service.Example_AuthorizationOptions_Policies_0_Groups_0" DefaultValue="Domain Users" />
</Parameters>
<ServiceManifestImport>
<ServiceManifestImport>
<ServiceManifestRef ServiceManifestName="Service.ExamplePkg" ServiceManifestVersion="1.0.0" />
<ConfigOverrides>
<ConfigOverride Name="Config">
<Settings>
<Section Name="AuthorizationOptions">
<Parameter Name="Policies:0:Name" Value="[Service.Example_AuthorizationOptions_Policies_0_Name]" />
<Parameter Name="Policies:0:Groups:0" Value="[Service.Example_AuthorizationOptions_Policies_0_Groups_0]" />
</Section>
</Settings>
</ConfigOverride>
</ConfigOverrides>
<EnvironmentOverrides CodePackageRef="code">
<EnvironmentVariable Name="ASPNETCORE_ENVIRONMENT" Value="[Service.Example_ASPNETCORE_ENVIRONMENT]" />
</EnvironmentOverrides>
</ServiceManifestImport>
<DefaultServices>
<Service Name="Service.Example" ServicePackageActivationMode="ExclusiveProcess">
<StatelessService ServiceTypeName="Service.ExampleType" InstanceCount="[Service.Example_InstanceCount]">
<SingletonPartition />
</StatelessService>
</Service>
</DefaultServices>
</ApplicationManifest>
Example Application ApplicationParameters (Local.1Node.xml):
<?xml version="1.0" encoding="utf-8"?>
<Application xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Name="fabric:/ServiceFabric.Example" xmlns="http://schemas.microsoft.com/2011/01/fabric">
<Parameters>
<Parameter Name="Service.Example_ASPNETCORE_ENVIRONMENT" Value="Development" />
<Parameter Name="Service.Example_InstanceCount" Value="-1" />
<Parameter Name="Service.Example_AuthorizationOptions_Policies_0_Name" Value="Users" />
<Parameter Name="Service.Example_AuthorizationOptions_Policies_0_Groups_0" Value="Domain Users" />
</Parameters>
</Application>
Example Application PublishProfiles (Local.1Node.xml):
<?xml version="1.0" encoding="utf-8"?>
<PublishProfile xmlns="http://schemas.microsoft.com/2015/05/fabrictools">
<ClusterConnectionParameters />
<ApplicationParameterFile Path="..\ApplicationParameters\Local.1Node.xml" />
</PublishProfile>
Should be unrelated, but example consumption of the settings:
internal sealed class Example : StatelessService
{
public Example(StatelessServiceContext context)
: base(context)
{ }
protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners()
{
return new ServiceInstanceListener[]
{
new ServiceInstanceListener(serviceContext =>
new HttpSysCommunicationListener(serviceContext, "ServiceEndpoint", (url, listener) =>
{
ServiceEventSource.Current.ServiceMessage(serviceContext, $"Starting HttpSys on {url}");
return new WebHostBuilder()
.UseHttpSys(options =>
{
options.Authentication.Schemes = AuthenticationSchemes.Negotiate; // Microsoft.AspNetCore.Server.HttpSys
options.Authentication.AllowAnonymous = false;
}).ConfigureServices(services => services.AddSingleton<StatelessServiceContext>(serviceContext))
.UseContentRoot(Directory.GetCurrentDirectory())
.ConfigureAppConfiguration((hostingContext, config) =>
{
config.SetBasePath(Directory.GetCurrentDirectory());
config.AddServiceFabricConfiguration(FabricRuntime.GetActivationContext(), options => {
options.IncludePackageName=false;
});
})
.UseStartup<Startup>()
.UseServiceFabricIntegration(listener, ServiceFabricIntegrationOptions.None)
.UseUrls(url)
.Build();
}))
};
}
}
From that point forward everything is in the IConfiguration object as expected.
There are many ways to configure a service fabric application, and each approach will bring you to a different challenges.
SF team recommend the approach in the docs, because you can have a better version control of configurations, and makes harder to commit mistakes, as it is explicitly declared in a file, I've used a few different approaches because of limitations like yours, the follwoing approach might solve your problem:
Configure like the original approach, but with complex types stored as JSON values: it is the closest solution to the recommended design and you still can keep control of the configuration versions on source control.
It would be something like:
Settings.xml:
<?xml version="1.0" encoding="utf-8" ?>
<Settings xmlns... namespaces here...>
<Section Name="AuthorizationOptions">
<Parameter Name="Policies"/>
</Section>
</Settings>
ApplicationManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<ApplicationManifest ApplicationTypeName="ServiceFabric.ExampleType" ApplicationTypeVersion="1.0.0" xmlns:...namespaces....>
<Parameters>
<Parameter Name="Service.Example_ASPNETCORE_ENVIRONMENT" DefaultValue="" />
<Parameter Name="Service.Example_InstanceCount" DefaultValue="-1" />
<Parameter Name="Service.Example_AuthorizationOptions_Policies" DefaultValue="[]" />
</Parameters>
<ServiceManifestImport>
<ServiceManifestImport>
<ServiceManifestRef ServiceManifestName="Service.ExamplePkg" ServiceManifestVersion="1.0.0" />
<ConfigOverrides>
<ConfigOverride Name="Config">
<Settings>
<Section Name="AuthorizationOptions">
<Parameter Name="Policies" Value="[Service.Example_AuthorizationOptions_Policies]" />
</Section>
</Settings>
</ConfigOverride>
</ConfigOverrides>
<EnvironmentOverrides CodePackageRef="code">
<EnvironmentVariable Name="ASPNETCORE_ENVIRONMENT" Value="[Service.Example_ASPNETCORE_ENVIRONMENT]" />
</EnvironmentOverrides>
</ServiceManifestImport>
<DefaultServices>
<Service Name="Service.Example" ServicePackageActivationMode="ExclusiveProcess">
<StatelessService ServiceTypeName="Service.ExampleType" InstanceCount="[Service.Example_InstanceCount]">
<SingletonPartition />
</StatelessService>
</Service>
</DefaultServices>
</ApplicationManifest>
ApplicationParameters.xml
<?xml version="1.0" encoding="utf-8"?>
<Application Name="fabric:/ServiceFabric.Example" xmlns:...namespaces....>
<Parameters>
<Parameter Name="Service.Example_ASPNETCORE_ENVIRONMENT" Value="Development" />
<Parameter Name="Service.Example_InstanceCount" Value="-1" />
<Parameter Name="Service.Example_AuthorizationOptions_Policies" Value="[{'Name': 'User','Groups': ['Domain Users']}, {'Name': 'Admin','Groups': ['Administrators']}]" />
</Parameters>
</Application>
In your service code:
public class Policy
{
public string Name { get; set; }
public string[] Groups { get; set; }
}
var settings = this.Context.CodePackageActivationContext.GetConfigurationPackageObject("Config").Settings;
var authOptions = settings.Sections["AuthorizationOptions"].Parameters["Policies"].Value;
var obj = JsonConvert.DeserializeObject<Policy[]>(authOptions);
You could go a level further and store the entire
AuthorizationOptions as a JSON, but like said previously, more
generic it become, easier will be to commit mistakes and harder to find
configuration issues.

Zend Navigation Find Page and Render Menu with its Subpages

I am putting together a Zend Navigation for a site with 4 different levels of access: Guest, Member1, Member2, and Admin.
My navigation XML looks something like this:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<nav>
<default>
<label>Home</label>
<controller>index</controller>
<action>index</action>
<resource>index</resource>
<privilege>index</privilege>
<pages>
<home>
...
</home>
<signin>
...
</signin>
<signup>
...
</signup>
</pages>
</default>
<member1>
<label>Member1 Main</label>
<controller>member1</controller>
<action>index</action>
<resource>member1</resource>
<privilege>index</privilege>
<pages>
<dashboard>
...
</dashboard>
<settings>
<label>Settings</label>
<controller>auth</controller>
<action>editpassword</action>
<resource>auth</resource>
<privilege>editpassword</privilege>
<class>settings</class>
<title>User settings</title>
<pages>
<account>
...
</account>
<logout>
...
</logout>
</pages>
</settings>
</pages>
</member1>
<member2>
<label>Member2 Main</label>
<controller>member2</controller>
<action>index</action>
<resource>member2</resource>
<privilege>index</privilege>
<pages>
<dashboard>
...
</dashboard>
<profile>
...
</profile>
<settings>
<label>Settings</label>
<controller>auth</controller>
<action>editpassword</action>
<resource>auth</resource>
<privilege>editpassword</privilege>
<class>settings</class>
<pages>
<account>
...
</account>
<logout>
...
</logout>
</pages>
</settings>
</pages>
</member2>
<admin>
<label>Dashboard</label>
<controller>admin</controller>
<action>index</action>
<resource>admin</resource>
<privilege>index</privilege>
<pages>
<dashboard>
...
</dashboard>
<logout>
...
</logout>
</pages>
</admin>
</nav>
</config>
Since I am using submenus and want consistency for top menu, I want to use a Zend's findBy feature to locate current user's status and display that menu. This is done as such:
if ( $this->user ) {
$submenu = $this->navigation()->findOneByLabel('Member1 Main');
$options = array(
'ulClass' => 'navigation',
'renderParents' => true,
'minDepth' => null,
'maxDepth' => null
);
echo $this->navigation()->menu()->renderMenu($submenu, $options);
} else {
echo $this->navigation()->menu()->setUlClass('navigation')->setOnlyActiveBranch(true)->setMinDepth(1)->setMaxDepth(1);
}
My Bootstrap bit for Nav is pretty generic and looks like this:
function _initNavigation()
{
$this->bootstrap('layout');
$layout = $this->getResource('layout');
$view = $layout->getView();
$navConfig = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml', 'nav');
$navigation = new Zend_Navigation($navConfig);
$front = Zend_Controller_Front::getInstance();
$myPlagin = $front->getPlugin('My_Controller_Plugin_Acl');
$view->navigation($navigation)->setAcl($myPlagin->getMyAcl())
->setRole($myPlagin->getMyUserRole());
}
Now, I can get the "Member1 Main" page to appear, but it only shows that one page, but what I need to render is that page's whole submenu. It seems that findOneByLabel only looks up that particular page only and not its descendants. Is there a way to pull the whole submenu?
Thanks.
Turns out I had to use findAllByLabel to get the expected result. Thanks #RockyFord

OpenJPA orphan removal not working

I am trying out a master child test case with a OneToMany unidirectional relationship.
I have a scenario where I want to update the master by removing some entries from the children list. When I do a merge, I want these child entries to be automatically deleted.
I have tried in vain to get this working. I tried orphanremoval too, but that too didn't help. There were some suggestions to add equals and hashcode, which didn't work either.
Any hint or help in this regard is highly appreciated. Thank you.
I am using JPA2.0 with OpenJPA 2.1.0
Here is my code.
//Parent class
public class Account {
private String accountId;
private String accountNumber;
private List<SubAccount> subAccounts;
//followed by getters/setters
}
//Child class
public class SubAccount {
private String subAccountId;
private String subAccountNumber;
//followed by getters/setters
}
My orm.xml is as follows.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<entity-mappings version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_2_0.xsd">
<entity name="Account" class="test.data.Account">
<table name="ACCOUNT" />
<sequence-generator name="AccountSeq"
sequence-name="ACCOUNT_TEST_SEQ" />
<attributes>
<id name="accountId">
<column name="ACCOUNT_ID" />
<generated-value strategy="SEQUENCE" generator="AccountSeq" />
</id>
<basic name="accountNumber">
<column name="ACCOUNT_NO" />
</basic>
<one-to-many name="subAccounts" fetch="EAGER"
target-entity="test.data.SubAccount" orphan-removal="true" >
<join-column name="ACCOUNT_ID" referenced-column-name="ACCOUNT_ID" nullable="false" updatable="true"/>
<cascade>
<cascade-all />
</cascade>
</one-to-many>
</attributes>
</entity>
<entity name="SubAccount" class="test.data.SubAccount">
<table name="SUBACCOUNT" />
<sequence-generator name="SubAccountSeq"
sequence-name="SUBACCOUNT_TEST_SEQ" />
<attributes>
<id name="subAccountPK">
<column name="SUBACCOUNT_ID" />
<generated-value strategy="SEQUENCE" generator="AccountSeq" />
</id>
<basic name="subAccountNumber">
<column name="SUBACCOUNT_NO" />
</basic>
</attributes>
</entity>
</entity-mappings>
And this is what I am trying to do.
Account acc = (Account)entityMgr.find(Account.class, "1100")
acc.getSubAccounts().remove(0);
entityMgr.merge(acc)
I expect the subaccount to be deleted.
OpenJPA overrides the orphan-removal behavior if the cascade type is set to cascade-all or cascade-remove.
Instead of cascade-all, I had to configure cascade-type with cascade-persist, cascade-merge, cascade-refresh and cascade-detach.

Zend Navigation - Rendering a submenu

I define all my pages in a XML file like the following:
<?xml version="1.0" encoding="UTF-8"?>
<configdata>
<nav>
<dashboard>
<label>Dashboard</label>
<module>default</module>
<controller>dashboard</controller>
<action>index</action>
<title>Die Schaltzentrale</title>
</dashboard>
<user>
<label>User</label>
<module>default</module>
<controller>user</controller>
<action>index</action>
<title>Verwaltung der Benutzer</title>
<userList>
<module>default</module>
<controller>user</controller>
<action>index</action>
<label>Userliste anzeigen</label>
</userList>
<newUser>
<label>User anlegen</label>
<module>default</module>
<controller>user</controller>
<action>new</action>
</newUser>
<editUser>
<label>User bearbeiten</label>
<module>default</module>
<controller>user</controller>
<action>edit</action>
</editUser>
</user>
</nav>
</configdata>
In my bootstrap I setup my navigation like this:
protected function _initNavigation()
{
$this->bootstrap('layout');
$layout = $this->getResource('layout');
$config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml','nav');
$view = $layout->getView();
$navigation = new Zend_Navigation($config);
$view->navigation($navigation);
Zend_Registry::set('Zend_Navigation',$navigation);
}
This setup enables me to render my main menu with the following lines:
$partial = array('menu.phtml', 'default');
$this->navigation()->menu()->setPartial($partial);
echo $this->navigation()->menu()->render();
So far so good. My problem is now to render a particular submenu. Let's say I want to render a menu with all actions of the user controller. I tried to render it with:
$page = $this->navigation()->findOneBy('controller','user');
echo $this->navigation()->menu()->renderMenu($page);
But I got no output. I also tried to obtain an output by setting the minDepth or maxDepth option without any success. Has anyone a hind for me, how I can bring it to work?
Your approach is very close. Change the findOneBy line to:
$page = $this->navigation()->findOneBy('label','User');
This will fetch all the pages under the User page.
I do not think it is possible to find a page by controller.
[edit]
I have modified your xml by adding a 'pages' section under user. This tells Zend Navigation that userList, newUser and editUser are sub-pages of user:
<?xml version="1.0" encoding="UTF-8"?>
<configdata>
<nav>
<dashboard>
<label>Dashboard</label>
<module>default</module>
<controller>dashboard</controller>
<action>index</action>
<title>Die Schaltzentrale</title>
</dashboard>
<user>
<label>User</label>
<module>default</module>
<controller>user</controller>
<action>index</action>
<title>Verwaltung der Benutzer</title>
<pages>
<userList>
<module>default</module>
<controller>user</controller>
<action>index</action>
<label>Userliste anzeigen</label>
</userList>
<newUser>
<label>User anlegen</label>
<module>default</module>
<controller>user</controller>
<action>new</action>
</newUser>
<editUser>
<label>User bearbeiten</label>
<module>default</module>
<controller>user</controller>
<action>edit</action>
</editUser>
</pages>
</user>
</nav>
</configdata>

Zend Framework - how to apply icon in xml file and retriev it

When it load the xml file, the icon cause failure inside the label tags. How to fix it?
// horizontal top menu
<?xml version="1.0" encoding="UTF-8"?>
<root>
<nav>
<page1>
<label><img src='icon.icon' /> Page 1</label>
<controller>index</controller>
</page1>
<home>
<label>Home</label>
<controller>index</controller>
</home>
</nav>
</root>
// controller test
$config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml', 'nav');
$container = new Zend_Navigation($config);
$this->view->navigation($container);
I suppose you could do it with CSS instead
// horizontal top menu
<?xml version="1.0" encoding="UTF-8"?>
<root>
<nav>
<page1>
<label>Page 1</label>
<controller>index</controller>
<class>menu-page1-icon</class>
</page1>
</nav>
</root>
CSS
.menu-page1-icon:before {
content: url(path/to/icon.icon);
}
It should probably be in a cdata section:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<nav>
<page1>
<label><![CDATA[<img src='icon.icon' /> Page 1]]></label>
<controller>index</controller>
</page1>
<home>
<label>Home</label>
<controller>index</controller>
</home>
</nav>
</root>
http://msdn.microsoft.com/en-us/library/ms256076.aspx