i have this xml file for Creating a container ,
if i want create a db for save this items and and create container from db
how should i do ?
<?xml version="1.0" encoding="utf-8"?>
<config>
<nav>
<logout>
<label>logout</label>
<controller>authentication</controller>
<action>logout</action>
<resource>logout</resource>
</logout>
<login>
<label>login</label>
<controller>authentication</controller>
<action>login</action>
<resource>login</resource>
</login>
<test>
<label>test</label>
<uri>#</uri>
<resource>test</resource>
<pages>
<list>
<label>list</label>
<controller>tset</controller>
<action>listtest</action>
</list>
<archive>
<label>archive</label>
<controller>myarchive</controller>
<action>archive</action>
</archive>
</pages>
</test>
</nav>
</config>
and code in bootsrap
$navContainerConfig = new Zend_Config_Xml(APPLICATION_PATH . 'navigation.xml', 'nav');
$navContainer = new Zend_Navigation($navContainerConfig);
Why do you need to store this in database?
If you really need, the best way is nested set.
You may also just serialize the array and save to the database.
You may also use Zend_Config_Xml_Writer instead of the database.
Related
I'm trying to update a custom field with a file type using rest API.
After properly uploading a file using:
curl --data-binary "#test.pdf" -H "Content-Type: application/octet-stream" -X POST -H "X-Redmine-API-Key: e1d815b8963e7b3950d4bea47959f874be755a2c" https://redmine-dev/uploads.xml
I get my token:
<?xml version="1.0" encoding="UTF-8"?>
<upload>
<id>15</id>
<token>15.cb4...</token>
</upload>
And then I tried to update the custom filed using those and none worked:
<?xml version="1.0"?>
<issue>
<custom_fields type="array">
<custom_field id="4">
<token>15.cb4...</token>
<filename>test.pdf</filename>
</custom_field>
</custom_fields>
</issue>
<?xml version="1.0"?>
<issue>
<custom_fields type="array">
<custom_field id="4">
<value>
<token>15.cb4...</token>
<filename>test.pdf</filename>
</value>
</custom_field>
</custom_fields>
</issue>
<?xml version="1.0"?>
<issue>
<custom_fields type="array">
<custom_field id="4">
<value>15</value>
</custom_field>
</custom_fields>
</issue>
After each the field is cleared in the database.
Updating a different custom field (text and number based) alongside of each of those is working. I've also checked the docs and there is nothing detailing how to use REST to update custom attachments.
It was so easy after looking into the code, but the token has to belong to previously unused attachment.
<?xml version="1.0"?>
<issue>
<custom_fields type="array">
<custom_field id="4">
<value>
<token>15.cb4...</token>
</value>
</custom_field>
</custom_fields>
</issue>
I'm following the answer at the bottom of this question here: ASP.NET 5 web application as Azure Web Role? as I am trying to build an azure web role for asp.net core.
When I run the powershell script I get the error:
Error CloudServices077: Need to specify the physical directory for the virtual path 'Web/' of role
If anyone knows another way to use azure web roles in asp.net core then I am all for that too.
I'm using CSPack to try and configure this.
Powershell Script:
# path to cspack
$cspackPath = Join-Path $env:ProgramFiles 'Microsoft SDKs\Azure\.NET SDK\v2.8\bin\cspack.exe'
$PackagePath = 'I:\Users\MyUserName\Documents\visual studio 2015\Projects\SoundVast\SoundVast.Azure\SoundVast.cspkg'
$serviceDefinitionFile = 'I:\Users\MyUserName\Documents\visual studio 2015\Projects\SoundVast\SoundVast.Azure\ServiceDefinition.csdef'
$webRoleName = 'WebRole1'
$webRolePath = 'I:\Users\MyUserName\Documents\visual studio 2015\Projects\SoundVast\SoundVast.Azure'
# define the cspack parameters
$cspackParameter = #(
$serviceDefinitionFile,
"/role:$webRoleName;$webRolePath;",
"/sites:$webRoleName;SoundVast;$webRolePath",
"/out:$PackagePath"
)
# execute cspack
& $cspackPath #cspackParameter
ServiceDefinition.csdef
<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="SoundVast.Azure" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2015-04.2.6">
<WebRole name="WebRole1" vmsize="Small">
<Sites>
<Site name="Web">
<Bindings>
<Binding name="Endpoint1" endpointName="Endpoint1" />
</Bindings>
</Site>
</Sites>
<ConfigurationSettings>
<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" />
</ConfigurationSettings>
<Endpoints>
<InputEndpoint name="Endpoint1" protocol="http" port="80" />
</Endpoints>
</WebRole>
</ServiceDefinition>
ServiceConfiguration.Cloud & ServiceConfiguration.Local
<?xml version="1.0" encoding="utf-8"?>
<ServiceConfiguration serviceName="SoundVast.Azure" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="4" osVersion="*" schemaVersion="2015-04.2.6">
<Role name="WebRole1">
<Instances count="1" />
<ConfigurationSettings>
<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="UseDevelopmentStorage=true" />
</ConfigurationSettings>
</Role>
</ServiceConfiguration>
Folder structure (if it makes a difference...)
I was missing the phsycial directory on this line: <Site name="Web" physicalDirectory="../SoundVast">. After this I ran the script and it created a package for me. The documentation on this is really not good.
<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="SoundVast.Azure" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2015-04.2.6">
<WebRole name="WebRole1" vmsize="Small">
<Sites>
<Site name="Web" physicalDirectory="../SoundVast">
<Bindings>
<Binding name="Endpoint1" endpointName="Endpoint1" />
</Bindings>
</Site>
</Sites>
<ConfigurationSettings>
<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" />
</ConfigurationSettings>
<Endpoints>
<InputEndpoint name="Endpoint1" protocol="http" port="80" />
</Endpoints>
</WebRole>
</ServiceDefinition>
I encountered this issue and resolved it by deleting the web role from my cloud service (it was an MVC) and generating a new one. I had made so many modifications it had become messy, so making a new one from scratch solved the issue
Can I remove the Home element from the XML file containing menus.
<?xml version="1.0" encoding="UTF-8"?>
<configdata>
<nav>
<label>HOME</label>
<controller>index</controller>
<action>index</action>
<id>root</id>
<pages>...</pages>
....
When I delete it from the xml file (from line 4 to 7), I get an exception
Zend_Navigation_Exception: Invalid argument: Unable to determine class to instantiate in C:\www\project\library\Zend\Navigation\Page.php on line 235
Well , you remove lines related to Home element in addition to the <nav> tag !!!
and then XML file becomes
<?xml version="1.0" encoding="UTF-8"?>
<configdata>
<menu1>...</menu1>
<menu2>...</menu2>
...
</configdata>
With zend framework how do i create a single level menu?
I followed a tutorial and the person created a two level dropdown menu. I want to just remove home. I've modified the navigation.xml file a couple times and it caused a fatal error.
What xml markup do i need to promote the children of home as the parent level menus? As in i don't need a home button at all.
Desired outcome:
who
why
what
speaker
resources
Current outcome:
home
• who
• what
• when
• why
Current navigation.xml file:
<?xml version="1.0" encoding="UTF-8" ?>
<configdata>
<nav>
<home>
<label>Home</label>
<controller>page</controller>
<action>index</action>
<module>default</module>
<pages>
<why>
<label>why</label>
<controller>page</controller>
<action>why</action>
<module>default</module>
</why>
<who>
<label>who</label>
<controller>page</controller>
<action>who</action>
</who>
<resources>
<label>resources</label>
<controller>page</controller>
<action>resources</action>
</resources>
<signin>
<label>sign in</label>
<controller>account</controller>
<action>login</action>
<module>default</module>
</signin>
</pages>
</home>
</nav>
...
application/Bootstrap.php:
<?php function _initViewHelpers() {
$this->bootstrap('layout);
// ... Skipping to relevant part
$navContainerConfig = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml', 'nav');
$navContainer = new Zend_Navigation($navContainerConfig);
$view->navigation($navContainer);
} ?>
layouts/default.phtml
<div class="navigation"><?php print $this->navigation(); ?></div>
<?xml version="1.0" encoding="UTF-8" ?>
<configdata>
<nav>
<why>
<label>why</label>
<controller>page</controller>
<action>why</action>
<module>default</module>
</why>
<who>
<label>who</label>
<controller>page</controller>
<action>who</action>
</who>
<resources>
<label>resources</label>
<controller>page</controller>
<action>resources</action>
</resources>
<signin>
<label>sign in</label>
<controller>account</controller>
<action>login</action>
<module>default</module>
</signin>
</nav>
What about setMaxDepth() and setMinDepth()? You can set how deep you want your menu to be rendered:
<?= $this->navigation()->menu()
->setMinDepth(1)
->setMaxDepth(2)
->render() . PHP_EOL; ?>
Also, you can find more information about the navigation view helper in the official manual. These information are often more relevant than the ones you can find in tutorials.
you should be able to just adjust your container to display only the links you want displayed. In this case you would just remove the Home elements from your xml file.
<?xml version="1.0" encoding="UTF-8" ?>
<configdata>
<nav>
<pages>
<why>
<label>why</label>
<controller>page</controller>
<action>why</action>
<module>default</module>
</why>
<who>
<label>who</label>
<controller>page</controller>
<action>who</action>
</who>
<resources>
<label>resources</label>
<controller>page</controller>
<action>resources</action>
</resources>
<signin>
<label>sign in</label>
<controller>account</controller>
<action>login</action>
<module>default</module>
</signin>
</pages>
</nav>
When you remove the Home menu from the XML file , you get an exception
Zend_Navigation_Exception: Invalid argument: Unable to determine class to instantiate in C:\www\project\library\Zend\Navigation\Page.php on line 235
i am working on a module e.g "Mymodule", in which i need to filter the results. i.e. for Partners i created Partner.php and for Community i created Community.php in
Mymodule/Block/Partner.php
Mymodule/Block/Community.php
Now i wanted to access their code in frontend through Mymodule.XML
<block type="mymodule/partner" ......................... />
but this doesn't work on LIVE SERVER, although it does work on local Wamp server :( ... Any idea ?
Although when i access the default Mymodule.php code in the same and add the code i placed in partner and community file, it does work.
Is there something i am missing ?
First, you have to define the blocks in your module's config.xml:
<config>
<global>
<blocks>
<mymodule>
<class>Namespace_Mymodule_Block</class>
</mymodule>
</blocks>
</global>
</config>
Second, you have to use the right block type in your layout XML:
<block type="mymodule/partner" ......................... />
You must not write ".php" in the block type. Note, that the term "mymodule" has to be the same in the config xml as well as in the block type.
Hope this helps!
I'm not strictly sure how your code would ever have worked. But assuming you haven't built a module before, you'll need a minimum of 3 files.
app/etc/modules/Sonassi_Module.xml
app/code/community/Sonassi/Module/etc/config.xml
app/code/community/Sonassi/Module/Block/Partner.php
In the first file ... app/etc/modules/Sonassi_Module.xml
<?xml version="1.0"?>
<config>
<modules>
<Sonassi_Module>
<active>true</active>
<codePool>community</codePool>
</Sonassi_Module>
</modules>
</config>
In the second file ... app/code/community/Sonassi/Module/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Sonassi_Module>
<version>0.1.0</version>
</Sonassi_Module>
</modules>
<frontend>
<routers>
<module>
<use>standard</use>
<args>
<module>Sonassi_Module</module>
<frontName>module</frontName>
</args>
</module>
</routers>
</frontend>
<global>
<blocks>
<module>
<class>Sonassi_Module_Block</class>
</module>
</blocks>
</global>
</config>
In the third file ... app/code/community/Sonassi/Module/Block/Partner.php
class Sonassi_Module_Block_Partner extends Core_Block_Template
{
}
Then finally, you can then use
<block type="module/partner" ......................... />