zend navigation single level menu using xml file - zend-framework

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

Related

Extra namespace in xsl output eclipse

Since our company is moving from AX to SAP I'm also making a 'shift' from visual studio to eclipse. I'd thought it would be nice to start with a small xslt project but when trying my existing (made in VS) xsl I noticed some differences.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="http://schemas.microsoft.com/dynamics/2008/01/documents/SalesInvoice">
<xsl:output method="xml" indent="yes" />
<xsl:strip-space elements="*" />
<xsl:template match="#*|node()">
<xsl:copy>
<xsl:apply-templates select="#*|node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="msxsl:SalesType">
<xsl:choose>
<xsl:when test="(../msxsl:SalesType) = 'ReturnItem'">
<xsl:element name="MessageType" namespace="http://schemas.microsoft.com/dynamics/2008/01/documents/SalesInvoice">384</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="MessageType" namespace="http://schemas.microsoft.com/dynamics/2008/01/documents/SalesInvoice">380</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
Generates an output xml with msxsl prefix xmlns:msxsl="http://schemas.microsoft.com/dynamics/2008/01/documents/SalesInvoice">380:
<?xml version="1.0" encoding="UTF-8"?>
<Envelope
xmlns="http://schemas.microsoft.com/dynamics/2008/01/documents/Message">
<Header>
<MessageId>{0E415D3C-6D46-4E4E-B8CA-9729B11BA}</MessageId>
<SourceEndpoint>BAB</SourceEndpoint>
<DestinationEndpoint>INVOIC_WKMP</DestinationEndpoint>
<Action>http://schemas.microsoft.com/dynamics/2008/01/services/SalesSalesInvoiceService/read
</Action>
</Header>
<Body>
<MessageParts>
<SalesInvoice xmlns="http://schemas.microsoft.com/dynamics/2008/01/documents/SalesInvoice">
<CustInvoiceJour class="entity">
<AccountcategoryId>FFF</AccountcategoryId>
<msxsl:MessageType
xmlns:msxsl="http://schemas.microsoft.com/dynamics/2008/01/documents/SalesInvoice">380</msxsl:MessageType>
</CustInvoiceJour>
</SalesInvoice>
</MessageParts>
</Body>
</Envelope>
Whereas visual studio xsl leaves out the xmlns:msxsl specification (which is correct):
<?xml version="1.0" encoding="utf-8"?>
<Envelope xmlns="http://schemas.microsoft.com/dynamics/2008/01/documents/Message">
<Header>
<MessageId>{0E415D3C-6D46-4E4E-B8CA-9729B11BA}</MessageId>
<SourceEndpoint>BAB</SourceEndpoint>
<DestinationEndpoint>INVOIC_WKMP</DestinationEndpoint>
<Action>http://schemas.microsoft.com/dynamics/2008/01/services/SalesSalesInvoiceService/read</Action>
</Header>
<Body>
<MessageParts>
<SalesInvoice xmlns="http://schemas.microsoft.com/dynamics/2008/01/documents/SalesInvoice">
<CustInvoiceJour class="entity">
<AccountcategoryId>FFF</AccountcategoryId>
<MessageType>380</MessageType>
</CustInvoiceJour>
</SalesInvoice>
</MessageParts>
</Body>
</Envelope>
Since it’s already in the http://schemas.microsoft.com/dynamics/2008/01/documents/SalesInvoice namespace
I don’t want this addition here. Is there anything I can do to change this in eclipse?
Kind regards,
Mike
No, Visual Studio is NOT correct to omit this namespace. If you don't want it included you should explicitly omit it using xsl:exclude-result-prefixes="msxsl".

Joomla 3 cannot disable custom plugin

I just installed a custom plugin in Joomla 3 and now I cannot disable it.
When I click disable (or edit) I receive "Internal Server Error".
xml file:
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.0" type="plugin" group="content">
<name>Content - Availability Calendar</name>
<author>Joomla! Project</author>
<creationDate>2010</creationDate>
<copyright>Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.</copyright>
<license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
<authorEmail>support#msc.gr</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>1.5</version>
<description></description>
<files>
<filename plugin="calendar">calendar.php</filename>
<filename>index.html</filename>
</files>
<params>
<param name="unit_id" type="text" size="5" default="50" label="Villa ID" description="Villa ID"/>
</params>
</extension>
You're XML code is old and is based on the code used for Joomla 1.5. You need to replace the following:
<params>
<param name="unit_id" type="text" size="5" default="50" label="Villa ID" description="Villa ID"/>
</params>
with this:
<config>
<fields name="params">
<fieldset name="basic">
<field name="unit_id" type="text" size="5" default="50" label="Villa ID" description="Villa ID"/>
</fieldset>
</fields>
</config>
Then for each new parameter you want to add, simply add a new <field>

Remove Home element from navigation in Zend_Navigation

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>

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

zend-framework navigation

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.