Extensible web admin

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Extensible web admin

Emmanuel Bouton
Hello,

I'm working on a web admin interface with Zend Framework 2, and I'd like to
make it extensible by « plugins ». Great for me ZF2 provides a great
modules system :)
But I wonder how I could make « cleanly » my templates extensible.

Example :

My « core » admin would render that :

<nav>
    <ul>
        <li><a href="">Home</a></li>
        <li><a href="">First link</a></li>
        <li><a href="">Second link</a></li>
    </ul>
</nav>

And I want that people could develop modules that could add links to my
main menu :

<nav>
    <ul>
        <li><a href="">Home</a></li>
        <li><a href="">First link</a></li>
        <li><a href="">Second link</a></li>
        <li><a href="">Super cool link from 1st plugin</a></li>
        <li><a href="">Another awesome link from 1st plugin</a></li>
        <li><a href="">Great link from 2nd plugin</a></li>
    </ul>
</nav>

How can I manage that in my core views / controllers ?

Thanks,
Best regards,
Emmanuel
Reply | Threaded
Open this post in threaded view
|

Re: Extensible web admin

Wojciech Nowogrodzki
Hi,

One of the solutions could be create service i.e.
MyAwesomeAppPluginManager with methods: navAdd(), navGet(), navGetAll(),
navExist(), etc...

Let's assume that navGetAll() will return an array of added options i.e.:
array(
     0 => array('url' => 'http://domain/first_url', 'name' => 'Super
cool link from 1st plugin'),
     1 => array('url' => 'http://domain/second_url', 'name' => 'Another
awesome link from 1st plugin')
)

Then you can inject this array to your view as $pluginsMenuOptions:
<nav>
     <ul>
         <li><a href="">Home</a></li>
         <li><a href="">First link</a></li>
         <li><a href="">Second link</a></li>
         <?php foreach($pluginsMenuOptions as $pluginMenuOption): ?>
             <li><a href="<?php echo $pluginMenuOption['url'] ?>"><?php
echo $pluginMenuOption['name'] ?></a></li>
         <?php endforeach; ?>
     </ul>
</nav>

After that you or someone else can create a plugin (i.e. external
library module). In Module.php method onBootstrap() one gets service
'MyAwesomeAppPluginManager' and sets navigation options by calling
navAdd() method...

Of course service 'MyAwesomeAppPluginManager' could also manage another
aspects of system (not only menu options).

That was my firstthought how it could be solved.

W dniu 06.06.2014 10:01, Emmanuel Bouton pisze:

> Hello,
>
> I'm working on a web admin interface with Zend Framework 2, and I'd like to
> make it extensible by « plugins ». Great for me ZF2 provides a great
> modules system :)
> But I wonder how I could make « cleanly » my templates extensible.
>
> Example :
>
> My « core » admin would render that :
>
> <nav>
>      <ul>
>          <li><a href="">Home</a></li>
>          <li><a href="">First link</a></li>
>          <li><a href="">Second link</a></li>
>      </ul>
> </nav>
>
> And I want that people could develop modules that could add links to my
> main menu :
>
> <nav>
>      <ul>
>          <li><a href="">Home</a></li>
>          <li><a href="">First link</a></li>
>          <li><a href="">Second link</a></li>
>          <li><a href="">Super cool link from 1st plugin</a></li>
>          <li><a href="">Another awesome link from 1st plugin</a></li>
>          <li><a href="">Great link from 2nd plugin</a></li>
>      </ul>
> </nav>
>
> How can I manage that in my core views / controllers ?
>
> Thanks,
> Best regards,
> Emmanuel
>

--
*Wojciech Nowogrodzki*
Reply | Threaded
Open this post in threaded view
|

Re: Extensible web admin

Stefano Torresi
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Extensible web admin

Emmanuel Bouton
Thanks a lot for all your responses !
SpiffyNavigation + use of placeholders seems to fit perfectly to my need.
Let's dig into that :)


2014-06-06 12:28 GMT+02:00 Stefano Torresi <[hidden email]>:

> you can use Zend\Navigation or, even better, Spiffy Navigation (
> https://github.com/spiffyjr/spiffy-navigation).
>
> just register a navigation instance as a service and have it composed by
> modules configuration, or decorate it in your modules via the service
> manager.
>
> for other templating stuff, i would suggest a full set of placeholders in
> a master layout, which your users can then manipulate in their own layouts,
> via view helpers or output capture.
>
> Stefano Torresi
> Web Developer
>
>
> 2014-06-06 10:25 GMT+02:00 Wojciech Nowogrodzki <[hidden email]>:
>
>>  Hi,
>>
>> One of the solutions could be create service i.e.
>> MyAwesomeAppPluginManager with methods: navAdd(), navGet(), navGetAll(),
>> navExist(), etc...
>>
>> Let's assume that navGetAll() will return an array of added options i.e.:
>> array(
>>     0 => array('url' => 'http://domain/first_url', 'name' => 'Super cool
>> link from 1st plugin'),
>>     1 => array('url' => 'http://domain/second_url', 'name' => 'Another
>> awesome link from 1st plugin')
>> )
>>
>> Then you can inject this array to your view as $pluginsMenuOptions:
>>
>> <nav>
>>     <ul>
>>         <li><a href="">Home</a></li>
>>         <li><a href="">First link</a></li>
>>         <li><a href="">Second link</a></li>
>>         <?php foreach($pluginsMenuOptions as $pluginMenuOption): ?>
>>             <li><a href="<?php echo $pluginMenuOption['url'] ?>"><?php
>> echo $pluginMenuOption['name'] ?></a></li>
>>         <?php endforeach; ?>
>>     </ul>
>> </nav>
>>
>> After that you or someone else can create a plugin (i.e. external library
>> module). In Module.php method onBootstrap() one gets service
>> 'MyAwesomeAppPluginManager' and sets navigation options by calling navAdd()
>> method...
>>
>> Of course service 'MyAwesomeAppPluginManager' could also manage another
>> aspects of system (not only menu options).
>>
>> That was my firstthought how it could be solved.
>>
>>
>> W dniu 06.06.2014 10:01, Emmanuel Bouton pisze:
>>
>>  Hello,
>>>
>>> I'm working on a web admin interface with Zend Framework 2, and I'd like
>>> to
>>> make it extensible by « plugins ». Great for me ZF2 provides a great
>>> modules system :)
>>> But I wonder how I could make « cleanly » my templates extensible.
>>>
>>> Example :
>>>
>>> My « core » admin would render that :
>>>
>>> <nav>
>>>      <ul>
>>>          <li><a href="">Home</a></li>
>>>          <li><a href="">First link</a></li>
>>>          <li><a href="">Second link</a></li>
>>>      </ul>
>>> </nav>
>>>
>>> And I want that people could develop modules that could add links to my
>>> main menu :
>>>
>>> <nav>
>>>      <ul>
>>>          <li><a href="">Home</a></li>
>>>          <li><a href="">First link</a></li>
>>>          <li><a href="">Second link</a></li>
>>>          <li><a href="">Super cool link from 1st plugin</a></li>
>>>          <li><a href="">Another awesome link from 1st plugin</a></li>
>>>          <li><a href="">Great link from 2nd plugin</a></li>
>>>      </ul>
>>> </nav>
>>>
>>> How can I manage that in my core views / controllers ?
>>>
>>> Thanks,
>>> Best regards,
>>> Emmanuel
>>>
>>>
>> --
>> *Wojciech Nowogrodzki*
>>
>
>