Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
how to make the admin panel in the module
  • I have a module of News

    fuel\modules\news\classes\controller\news.php

    how to make the admin panel in the module

  • Impossible to say without knowing your application architecture.
  • HarroHarro
    Accepted Answer
    And you want to move that admin controller to your module?

    That should not be a problem, a matter of adding the namespace to the controller, and check that all class access is properly namespaced.

    If you then rename it to Controller_Admin (it doesn't need News in the name anymore), you will get a URL like /news/admin/....

    You can use a generic route like

    'admin/(:any)/(:any)' => '$1/admin/$2',

    which will allow you to use a url like admin/news/something, which will then be rewritten to news/admin/something. It allows you to, from a URL point of view, still group all your admin controllers under the /admin URL.


  • Is there any way to make it available as an  admin/news
     but in order to avoid conflicts with other pages?

  • Yes, using the route I gave.

    I assumed that you have multiple modules, and would want to do the same for all your modules. If not, you can always define a specific route:

    'admin/news(:any)' => 'news/admin$1',
  • 'admin/(:any)/(:any)' => '$1/admin/$2',   
    admin/news/news

    I mean, the path was not admin/news/news/edit/1

    but just admin/news/edit/1


    can be arranged once the files that it happened, and why not make the identification of ways in the nucleus sanctioned Frameworks

  • Eh, could be that the regex for :any is eager, so the segment is replicated.

    Use

    'admin/(:segment)/(:any)' => '$1/admin/$2',  

    instead.
  • you have written is not working

    I have tried to do so

    fuel/app/config/routes.php  -   'admin/(:any)/(:any)' => '$1/admin/$2',  

    modules/news/config/routes.php - 'admin/news' => 'admin/news/news',


    the documentation says that the modules can have your routing
    http://fuelphp.com/docs/general/modules.html#module_routing
     

    but still it does not work




  • What are you exactly trying to do where? You are adding a module route? Which route, and to which module?
  • I want to admin panel of the module "news" was available at admin/news


    modules/news/classes/controller/admin/news.php

    although the path to the admin panel can change the main thing that was available at admin/news

    modules may have different names

  • So you need to add that route to app/config/routes.php, module routes aren't loaded until the module itself is loaded, this limitation is documented.
  • So far I can not find a solutionI need to admin panel has been available in the controllers and modules in conventional controllers

    if you add

    'admin/(:segment)/(:any)' => '$1/admin/$2',

    fuel/app/classes/controller/admin/users.php  it works as /admin/users

    fuel/modules/news/classes/controller/admin/news.php   but does not work  /admin/news


    if done well

    'admin/(:segment)' => '$1/admin/$1',
    'admin/(:segment)/(:any)' => '$1/admin/$1/$2',

    on the contrary news work and the users do not


    I need to be available towards the controllers and modules, without modules

  • fuel/modules/news/classes/controller/admin/news.php has to be accessed (as in route target) as "news/admin/news/...". There is no way around that.

    /admin/news doesn't work, because this route converts that to "news/admin", which maps to a controller called "admin" in the news module. And not to a controller "news" in the admin folder of the news module.

    So all you can do is hardcode your global admin controllers:
    'admin/(users|other|global)/(:any)' => 'admin/$1/$2',
    'admin/(:segment)/(:any)' => '$1/admin/$1/$2',

    This will map

    admin/users/something to admin/users/something (app/classes/controller/admin/users.php, action something)
    admin/other/something to admin/other/something (app/classes/controller/admin/other.php, action something)
    admin/news/something to news/admin/news/something (modules/news/classes/controller/admin/news.php, action something)

    There is no way to magically detect where your controller lives, without using a route closure that does it's own class lookups and that constructs a new URI and call that with an HMVC call.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion