Layout links prefixed with plugin name when viewing plugin action

3 messages Options
Embed this post
Permalink
benr-2

Layout links prefixed with plugin name when viewing plugin action

Reply Threaded More More options
Print post
Permalink

I have a plugin to handle a portion of my application. The plugin
renders a view, but uses my default layout. The problem is that all my
links in the layout (which don't have anything to do with the plugin)
all get the plugin name prefixed to them. For example:

Regular link: http://domain.com/regularlink
In plugin view: http://domain.com/plugin_name/regularlink

I'm using $html->link() to create all my links and I know that you can
add 'plugin' => null to disable that routing behavior but it seems a
bit counter-intuitive to have to do that with every non-plugin link in
a layout just so you can use plugins.

Is there a way to set the baseUrl or somehow remove that prefix form
all links unless they explicitly have the 'plugin' => 'plugin_name'
key/value in the url array()?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Robert P-2

Re: Layout links prefixed with plugin name when viewing plugin action

Reply Threaded More More options
Print post
Permalink

This seems to be an issue traceable back to Router::url(). A possible
solution would be to extend the View class to override the renderLayout
() method.

The new renderLayout() would be something like:
    get Router instance
    remove plugin references
    parent::renderLayout()

I would be interested in hearing if this works.

On Nov 5, 1:09 am, benr <[hidden email]> wrote:

> I have a plugin to handle a portion of my application. The plugin
> renders a view, but uses my default layout. The problem is that all my
> links in the layout (which don't have anything to do with the plugin)
> all get the plugin name prefixed to them. For example:
>
> Regular link:http://domain.com/regularlink
> In plugin view:http://domain.com/plugin_name/regularlink
>
> I'm using $html->link() to create all my links and I know that you can
> add 'plugin' => null to disable that routing behavior but it seems a
> bit counter-intuitive to have to do that with every non-plugin link in
> a layout just so you can use plugins.
>
> Is there a way to set the baseUrl or somehow remove that prefix form
> all links unless they explicitly have the 'plugin' => 'plugin_name'
> key/value in the url array()?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

benr-2

Re: Layout links prefixed with plugin name when viewing plugin action

Reply Threaded More More options
Print post
Permalink

Thanks for the suggestion! We ended up taking a similar approach by
extending the HtmlHelper::url() function in the app_helper.php (based
on this article:
http://debuggable.com/posts/how-to-save-half-a-second-on-every-request-of-your-cakephp-app:49a69610-8648-4d65-815d-754c4834cda3):

<?php
// app_helper.php
class AppHelper extends Helper {

  function url($url = null, $full = false) {

 if( !isset($url['plugin']) ){
  $url['plugin'] = null;
 }

    return parent::url($url, $full);
  }
  
}
?>

Now you just have to make sure that any plugin URLs have the plugin
explicitly defined in the url array ('plugin' => 'plugin_name'), but
all other links will have 'plugin' => null set by default.

On Nov 4, 8:49 pm, Robert P <[hidden email]> wrote:

> This seems to be an issue traceable back to Router::url(). A possible
> solution would be to extend the View class to override the renderLayout
> () method.
>
> The new renderLayout() would be something like:
>     get Router instance
>     removepluginreferences
>     parent::renderLayout()
>
> I would be interested in hearing if this works.
>
> On Nov 5, 1:09 am, benr <[hidden email]> wrote:
>
>
>
> > I have apluginto handle a portion of my application. Theplugin
> > renders a view, but uses my default layout. The problem is that all my
> > links in the layout (which don't have anything to do with theplugin)
> > all get thepluginname prefixed to them. For example:
>
> > Regularlink:http://domain.com/regularlink
> > Inpluginview:http://domain.com/plugin_name/regularlink
>
> > I'm using $html->link() to create all my links and I know that you can
> > add 'plugin' => null to disable that routing behavior but it seems a
> > bit counter-intuitive to have to do that with every non-pluginlinkin
> > a layout just so you can use plugins.
>
> > Is there a way to set the baseUrl or somehow remove that prefix form
> > all links unless they explicitly have the 'plugin' => 'plugin_name'
> > key/value in the url array()?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---