Remove Home element from navigation in Zend_Navigation - zend-framework

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>

Related

What is wrong with my layer.xml from netbeans?

I try to create a new palette in netbeans 10, but the following 2 errors don't allow me to compile the project:
Document root element "folder", must match DOCTYPE root "JavaPalette". [3]
The markup in the document following the root element must be well-formed. [11]
My XML looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd">
<folder name="JavaPalette">
<folder name="Items">
<attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.javasourcefilepalette.Bundle"/>
<file name="Item.xml" url="resources/Item.xml">
<attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.javasourcefilepalette.Bundle"/>
</file>
</folder>
</folder>
<filesystem/>
I have no clue what both error messages mean, but i did exactly what is said in the tutorial.
Online validation of the xml file also shows that error.
https://platform.netbeans.org/tutorials/nbm-palette-api2.html
I didn´t followed the tutorial, but as far as i can tell, your filesystem tag is not valid. If you take a look at the DTD you can see that the element filesystem isn´t declared as EMPTY (for more information you can read more about it here). So you have to provide a start and end tag. In your posted example you are only using <filesystem/> which isn´t allowed.
You have to change the xml as follows:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd">
<filesystem>
<folder name="JavaPalette">
<folder name="Items">
<attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.javasourcefilepalette.Bundle"/>
<file name="Item.xml" url="resources/Item.xml">
<attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.javasourcefilepalette.Bundle"/>
</file>
</folder>
</folder>
</filesystem>

How to update custom fields with file type using REST in redmine?

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>

How to read xml value with Powershell

<?xml version="1.0" encoding="utf-8"?>
<Foo>
<Tier Path="\\10.10.44.61\Case Study\" />
<Force Path="\\10.10.44.61\Orto Study" Atomic="False" />
</Foo>
How can I read in powershell Tier Path value?
I am expecting to get the value of \\10.10.44.61\Case Study\
$xml = '<?xml version="1.0" encoding="utf-8"?>
<Foo>
<Tier Path="\\10.10.44.61\Case Study\" />
<Force Path="\\10.10.44.61\Orto Study" Atomic="False" />
</Foo>'
([xml]$xml).Foo.Tier.Path
As long as you are using an xml type (which I do by casting) you can reference the path directly as members of the object.

zend navigation single level menu using xml file

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

Namespace/Mymodule/Block/Item.php file code not accessible on frontend after adding through xml

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" ......................... />