dpvmjk0479 2015-10-04 12:45
浏览 20
已采纳

CakePHP访问插件控制器

Ok, so I am using a ReportManager plugin. I am able to use it as is by using this url: 'localhost/AppName/report_manager/reports'

Now, when I try to use it on the project I'm working on, I have a problem with accessing the plugin's controller.

I have a side bar which contains several links. Here's the code:

<div id="wrapper">
    <!-- Sidebar -->
    <div id="sidebar-wrapper">
        <ul class="sidebar-nav">
            <li id="sidebar-header">
                <?php
                    echo $this->Html->link(
                    'Home',
                        array(
                        'controller' => 'members',
                        'action' => 'index',

                        )
                    );
                ?>
            </li>
            <li id="sidebar-header">
                <?php
                    echo $this->Html->link(
                    'Messages',
                        array(
                        'controller' => 'members',
                        'action' => 'messages',

                        )
                    );
                ?>
            </li>

            <li id="sidebar-header">Misc</li>        
            <li>
                <?php
                    echo $this->Html->link(
                    'Received Documents',
                        array(
                        'controller' => 'members',
                        'action' => 'documents',

                        )
                    );
                ?>
            </li>

            <li id="sidebar-header">
                <?php
                    echo $this->Html->link(
                    'Calendar',
                        array(
                        'controller' => 'calendars',
                        'action' => 'calendar',

                        )
                    );
                ?>
            </li>
            <li>
                <?php
                    echo $this->Html->link(
                    'Manage Events',
                        array(
                        'controller' => 'events',
                        'action' => 'manage',

                        )
                    );
                ?>
            </li>

            <li id="sidebar-header">
                <?php
                    echo $this->Html->link(
                    'Reports',
                        array(
                        'controller' => 'reports',
                        'action' => 'index',

                        )
                    );
                ?>
            </li>

            <center><hr class="item-divider"></center>

            <li id="sidebar-header">
                <?php
                    echo $this->Html->link(
                    'Manage Accounts',
                        array(
                        'controller' => 'members',
                        'action' => 'manage_accounts',

                        )
                    );
                ?>
            </li>

            <li id="sidebar-header">
                <?php
                    echo $this->Html->link(
                    'Logout',
                        array(
                        'controller' => 'user',
                        'action' => 'logout',

                        )
                    );
                ?>
            </li>

        </ul>  
    </div>
</div>

So I have a link name 'Reports' that would open the ReportsManager plugin. So far I cannot figure it out how to access it.

I tried this one:

<li id="sidebar-header">
      <?php
          echo $this->Html->link(
         'Reports',
            array(
              'controller' => 'report_manager/reports',
              'action' => 'index',                          
                 )
          );
       ?>
 </li>

It works, but once you click other links you will see this on the url: 'localhost/AppName/report_manager/members/documents'

Any way I can fix this?

  • 写回答

1条回答 默认 最新

  • doumian3780 2015-10-04 15:29
    关注

    Add 'plugin' => 'PLUGIN NAME HERE'

    <li id="sidebar-header">
      <?php
          echo $this->Html->link(
         'Reports',
            array(
              'plugin' => 'report_manager',
              'controller' => 'reports',
              'action' => 'index',                          
                 )
          );
       ?>
    

    Other links 'plugin' => false

    <?php
        echo $this->Html->link(
          'Home',
           array(
              'plugin' => false,
              'controller' => 'members',
              'action' => 'index',
           )
        );
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?