Foros del Web » Programando para Internet » PHP » Zend »

Menu y perfiles

Estas en el tema de Menu y perfiles en el foro de Zend en Foros del Web. Hola!!!!! tengo 1 duda y un problemas, el problemas; estoy tratando de hacer un menu en zend, encontre un link que explica, pero me da ...
  #1 (permalink)  
Antiguo 13/02/2012, 09:35
 
Fecha de Ingreso: diciembre-2008
Mensajes: 805
Antigüedad: 15 años, 4 meses
Puntos: 20
Menu y perfiles

Hola!!!!! tengo 1 duda y un problemas,
el problemas;
estoy tratando de hacer un menu en zend, encontre un link que explica, pero me da error.
[PHP]
Cita:

Fatal error: Uncaught exception 'Zend_Loader_PluginLoader_Exception' with message 'Plugin by name 'GetView' was not found in the registry; used paths:
y la duda es que quiero hacer que cada usuario tenga su propio menu, por ejemplo si es usuario invitado, que se forme con los modulos y permisos que tiene, eso esa bien que lo haga con XML. desde ya muchas gracias !!!!
  #2 (permalink)  
Antiguo 13/02/2012, 10:25
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 10 meses
Puntos: 2135
Respuesta: Menu y perfiles

Pues ese error es complicado de resolver sin ver el código, y básicamente te dice que estas llamando a un plugin que no existe.

Lo otro a lo que te refieres, pues hay muchas formas de implementarlo, puedes usar un menu con Zend_Navigation e integrarle un Zend_Acl para los permisos, y ya renderearlo en tu view usando el helper que ya tiene.

Saludos.
  #3 (permalink)  
Antiguo 13/02/2012, 10:32
 
Fecha de Ingreso: diciembre-2008
Mensajes: 805
Antigüedad: 15 años, 4 meses
Puntos: 20
Respuesta: Menu y perfiles

Bien, el este es el codigo del primero
Código PHP:

  
protected function  _initnavigation()
    {

        
$this->bootstrap('view');
        
$layout $this->getResource('view');
        
$view $layout->getView(); 
esto esta el el bootstrap
  #4 (permalink)  
Antiguo 13/02/2012, 10:40
Avatar de masterpuppet
Software Craftsman
 
Fecha de Ingreso: enero-2008
Ubicación: Montevideo, Uruguay
Mensajes: 3.550
Antigüedad: 16 años, 3 meses
Puntos: 845
Respuesta: Menu y perfiles

Le estas haciendo getView al view..., deberia ser:

Código PHP:
Ver original
  1. $this->bootstrap('view');
  2. $view = $this->getResource('view');

o

Código PHP:
Ver original
  1. $this->bootstrap('layout');
  2. $layout = $this->getResource('layout');
  3. $view   = $layout->getView();

Saludos.
__________________
http://es.phptherightway.com/
thats us riders :)
  #5 (permalink)  
Antiguo 13/02/2012, 10:54
 
Fecha de Ingreso: diciembre-2008
Mensajes: 805
Antigüedad: 15 años, 4 meses
Puntos: 20
Respuesta: Menu y perfiles

bien, con la primera opcion no sale mas el error pero no me muestra el menu.

este es el codigo completo y este es link de donde lo saque

Código PHP:
        $this->bootstrap('view');
        
$layout $this->getResource('view');
        
$view $layout->getView();
        
$config = new Zend_Config_Xml(APPLICATION_PATH '/configs/navigation.xml''nav');
        
$navigation = new Zend_Navigation($config);
        
$view->navigation($navigation); 
http://www.zendcasts.com/zend_naviga...rumbs/2009/06/
  #6 (permalink)  
Antiguo 13/02/2012, 11:23
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 10 meses
Puntos: 2135
Respuesta: Menu y perfiles

Te faltaría imprimirlo en el view...

Código PHP:
Ver original
  1. <?php echo $this->navigation()->menu(); ?>

Saludos.
  #7 (permalink)  
Antiguo 13/02/2012, 11:36
 
Fecha de Ingreso: diciembre-2008
Mensajes: 805
Antigüedad: 15 años, 4 meses
Puntos: 20
Respuesta: Menu y perfiles

eso lo puse en la Layout
  #8 (permalink)  
Antiguo 13/02/2012, 11:40
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 10 meses
Puntos: 2135
Respuesta: Menu y perfiles

Otra opción es guardarlo en el registry el navigation:
Código PHP:
Ver original
  1. Zend_Registry::set('Zend_Navigation', $navigation);
  #9 (permalink)  
Antiguo 13/02/2012, 11:56
 
Fecha de Ingreso: diciembre-2008
Mensajes: 805
Antigüedad: 15 años, 4 meses
Puntos: 20
Respuesta: Menu y perfiles

mmm, disculpa pero, donde lo coloco??, estoy aprendiendo Zf
  #10 (permalink)  
Antiguo 13/02/2012, 12:05
 
Fecha de Ingreso: diciembre-2008
Mensajes: 805
Antigüedad: 15 años, 4 meses
Puntos: 20
Respuesta: Menu y perfiles

Bien lo coloque debajo en el Bootstrap, pero me sale el siguiente error:
Cita:

Fatal error: Uncaught exception 'Zend_Navigation_Exception' with message 'Invalid argument: Unable to determine class to instantiate' in /

el codigo quedo asi:

Código PHP:
$this->bootstrap('view');
        
$layout $this->getResource('view');
   
$config = new Zend_Config_Xml(APPLICATION_PATH '/configs/navigation.xml''nav');
        
$navigation = new Zend_Navigation($config);
 
Zend_Registry::set('Zend_Navigation'$navigation); 
  #11 (permalink)  
Antiguo 13/02/2012, 12:06
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 10 meses
Puntos: 2135
Respuesta: Menu y perfiles

En el bootstrap después de que creas tu Zend_Navigation.

Saludos.
  #12 (permalink)  
Antiguo 13/02/2012, 12:37
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 10 meses
Puntos: 2135
Respuesta: Menu y perfiles

¿Como estas creando tu XML?
  #13 (permalink)  
Antiguo 13/02/2012, 12:39
 
Fecha de Ingreso: diciembre-2008
Mensajes: 805
Antigüedad: 15 años, 4 meses
Puntos: 20
Respuesta: Menu y perfiles

ASi ::
Código PHP:

<?xml version="1.0" encoding="UTF-8"?>

<!--
    Document   : navigation.xml
    Created on : 6 de febrero de 2012, 17:26
    Author     : sergio
    Description:
        Purpose of the document follows.
-->

    <configdata>

            <nav>
                    <home>
                         <label>Clientes</label>
                            <pages>

                                    <label>about</label>

                                <uri>/</uri>
                            </pages>
                    </home>
            </nav>

    </configdata>
  #14 (permalink)  
Antiguo 13/02/2012, 12:51
 
Fecha de Ingreso: diciembre-2008
Mensajes: 805
Antigüedad: 15 años, 4 meses
Puntos: 20
Respuesta: Menu y perfiles

Este es el error completo que me sale

Cita:

Fatal error: Uncaught exception 'Zend_Navigation_Exception' with message 'Invalid argument: Unable to determine class to instantiate' in /var/www/qaz/library/Zend/Navigation/Page.php:223 Stack trace: #0 /var/www/qaz/library/Zend/Navigation/Container.php(117): Zend_Navigation_Page::factory(Array) #1 /var/www/qaz/library/Zend/Navigation/Container.php(164): Zend_Navigation_Container->addPage(Array) #2 /var/www/qaz/library/Zend/Navigation.php(46): Zend_Navigation_Container->addPages(Object(Zend_Config_Xml)) #3 /var/www/qaz/application/Bootstrap.php(31): Zend_Navigation->__construct(Object(Zend_Config_Xml)) #4 /var/www/qaz/library/Zend/Application/Bootstrap/BootstrapAbstract.php(666): Bootstrap->_initNavigation() #5 /var/www/qaz/library/Zend/Application/Bootstrap/BootstrapAbstract.php(619): Zend_Application_Bootstrap_BootstrapAbstract->_executeResource('navigation') #6 /var/www/qaz/library/Zend/Application/Bootstrap/BootstrapAbstract.php(583): Zend_Application_Bootstrap_BootstrapAbstract->_bootstrap(NULL) #7 /var/www/qaz/libra in /var/www/qaz/library/Zend/Navigation/Page.php on line 223
muchas gracias!!1
  #15 (permalink)  
Antiguo 13/02/2012, 12:54
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 10 meses
Puntos: 2135
Respuesta: Menu y perfiles

Lee en el Manual cual es la estructura que se necesita para el XML:

http://framework.zend.com/manual/en/...ontainers.html

Saludos.
  #16 (permalink)  
Antiguo 15/02/2012, 11:32
 
Fecha de Ingreso: abril-2010
Ubicación: Lima-Peru
Mensajes: 94
Antigüedad: 14 años
Puntos: 2
Información Respuesta: Menu y perfiles

hola yo lo trabajo asi:
mi /configs/navigation.xml:
Cita:
<?xml version="1.0" encoding="UTF-8"?>

<config>
<nav>
<customer>
<label>Clientes</label>
<module>customer</module>
<controller>customer</controller>
<action>index</action>
<resource>customer:customer</resource>
<privilege>index</privilege>
</customer>


<user>
<label>Usuarios</label>
<module>user</module>
<controller>user</controller>
<action>index</action>
<resource>user:user</resource>
<privilege>index</privilege>
</user>

</nav>
</config>
en el bootstrap.php lo tengo asi:

Código PHP:
protected function _initNavigation()
        {
       
$this->bootstrap('layout');
        
$layout $this->getResource('layout');
        
$view $layout->getView();
        
        
$navContainerConfig = new Zend_Config_Xml(APPLICATION_PATH.'/configs/navigation.xml''nav');
        
$navContainer = new Zend_Navigation($navContainerConfig);

        
$view->navigation($navContainer);


        } 
y lo llamo en el layout:

Código PHP:
<?php echo $this->navigation()->menu(); ?>
y funciona todo bien. Ahora para que cada usuario tenga su propio menú lo puedes trabajar con Zend ACL, que es algo similar con algunos cambios adicionales.

Saludos,
  #17 (permalink)  
Antiguo 16/02/2012, 06:28
 
Fecha de Ingreso: diciembre-2008
Mensajes: 805
Antigüedad: 15 años, 4 meses
Puntos: 20
Respuesta: Menu y perfiles

Bien, muchas Gracias!!! ahora si funciona! ahora voy a leer zend _ACL y cualquier cosa voy a molestar. JAJAJa!!! muchas gRacias
  #18 (permalink)  
Antiguo 01/05/2012, 04:46
 
Fecha de Ingreso: abril-2012
Mensajes: 3
Antigüedad: 12 años
Puntos: 0
Respuesta: Menu y perfiles

pues mi archivho donde tengo el layout se llama master.phtml, el tema que lo tengo asi el initNavigation :
Código PHP:
Ver original
  1. $this->bootstrap('layout');
  2.         $layout = $this->getResource('master');
  3.         $view = $layout->getView();
  4.        
  5.         $navContainerConfig = new Zend_Config_Xml(APPLICATION_PATH.'/configs/navigation.xml', 'nav');
  6.         $navContainer = new Zend_Navigation($navContainerConfig);
  7.        
  8.         $view->navigation($navContainer);
y mi xml es
Código XML:
Ver original
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <configdata>
  3.     <nav>
  4.         <home>
  5.             <label>Home</label>
  6.             <url>/</url>
  7.        
  8.         <pages>
  9.             <servicios>
  10.                 <label>Servicios</label>
  11.                 <url>/static-content/servicios</url>
  12.             </servicios>
  13.             <trabajos>
  14.                 <label>Trabajos</label>
  15.                 <url>/static-content/trabajos</url>
  16.             </trabajos>
  17.             <contacto>
  18.                 <label>Contacto</label>
  19.                 <url>/contacto/index</url>
  20.             </contacto>
  21.         </pages>
  22.         </home>
  23.     </nav>
  24. </configdata>
y me tira el error:
Fatal error: Call to a member function getView() on a non-object in C:\xampp\htdocs\jc\application\Bootstrap.php on line 51
y si en vez de poner master le pongo 'layout' me tira el error :
Fatal error: Uncaught exception 'Zend_Navigation_Exception' with message 'Invalid argument: Unable to determine class to instantiate' in C:\xampp\htdocs\Zend\library\Zend\Navigation\Page. php:261 Stack trace: #0 C:\xampp\htdocs\Zend\library\Zend\Navigation\Conta iner.php(117): Zend_Navigation_Page::factory(Array) #1 C:\xampp\htdocs\Zend\library\Zend\Navigation\Conta iner.php(172): Zend_Navigation_Container->addPage(Array) #2 C:\xampp\htdocs\Zend\library\Zend\Navigation.php(4 6): Zend_Navigation_Container->addPages(Object(Zend_Config_Xml)) #3 C:\xampp\htdocs\jc\application\Bootstrap.php(54): Zend_Navigation->__construct(Object(Zend_Config_Xml)) #4 C:\xampp\htdocs\Zend\library\Zend\Application\Boot strap\BootstrapAbstract.php(669): Bootstrap->_initNavigation() #5 C:\xampp\htdocs\Zend\library\Zend\Application\Boot strap\BootstrapAbstract.php(622): Zend_Application_Bootstrap_BootstrapAbstract->_executeResource('navigation') #6 C:\xampp\htdocs\Zend\library\Zend\Application\Boot strap\BootstrapAbstract.php(586): Zend_Application_Boots in C:\xampp\htdocs\Zend\library\Zend\Navigation\Page. php on line 261


A ver que alma caritativa me echa un cable , gracias
  #19 (permalink)  
Antiguo 01/05/2012, 06:06
Avatar de masterpuppet
Software Craftsman
 
Fecha de Ingreso: enero-2008
Ubicación: Montevideo, Uruguay
Mensajes: 3.550
Antigüedad: 16 años, 3 meses
Puntos: 845
Respuesta: Menu y perfiles

El recurso es layout no master y el nodo en el xml es uri no url.

Saludos.
__________________
http://es.phptherightway.com/
thats us riders :)
  #20 (permalink)  
Antiguo 01/05/2012, 08:04
 
Fecha de Ingreso: abril-2012
Mensajes: 3
Antigüedad: 12 años
Puntos: 0
Respuesta: Menu y perfiles

Cita:
Iniciado por masterpuppet Ver Mensaje
El recurso es layout no master y el nodo en el xml es uri no url.

Saludos.
Gracias, el tema es que el nodo lo llame url en vez de uri, pero mi archivo de layout se llamaba master, y por alguna razon no tomaba ese nombre, el tema es que funciona. Gracias fenomeno!

Etiquetas: perfiles, php
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 23:46.