Plugin question
Moderators: tjay, seadap, Rogue4ngel, matthewhayashida
-
- Joomla! Apprentice
- Posts: 6
- Joined: Tue Sep 11, 2007 8:24 am
Plugin question
I'm trying to execute some code just before any backend-components is displayed. What I want to do is check some user-parameters and redirect the user somewhere depending on these parameters. I know how to retrieve user parameter data, but the problem is that I can't find any plugin event which always triggers before an administration component loads, yet in which it's possible to redirect the user. I hoped anyone here knows how to do this?
Re: Plugin question
onAfterInitialise should do the trick, I think. Use $mainframe->isAdmin() in the plugin to make sure that it's only enabled in administration.
My Joomla! 1.5 extensions - http://joomla.ercan.us
Progress is made by lazy men looking for easier ways to do things.
Progress is made by lazy men looking for easier ways to do things.
-
- Joomla! Apprentice
- Posts: 6
- Joined: Tue Sep 11, 2007 8:24 am
Re: Plugin question
I can't seem to get it to work. The redirection doesn't go. I tried the following:
function onAfterInitialise()
{
global $mainframe;
$mainframe->redirect('index.php?option=com_media');
}
When I do the same in the onLoginUser event, the redirection does work like this. I would expect the above snippet to cause a redirection to the com_media component when I open any other section...
Any idea's?
function onAfterInitialise()
{
global $mainframe;
$mainframe->redirect('index.php?option=com_media');
}
When I do the same in the onLoginUser event, the redirection does work like this. I would expect the above snippet to cause a redirection to the com_media component when I open any other section...
Any idea's?
-
- Joomla! Apprentice
- Posts: 6
- Joined: Tue Sep 11, 2007 8:24 am
Re: Plugin question
Apparently it does work when I put my plugin in the system plugin folder.
There is another problem however. When I redirect to another page I get a browser error. Yet when I disable the plugin and refresh the very same page, it does work.
The browser error is that the page incorrectly redirects in a way that will never end...
There is another problem however. When I redirect to another page I get a browser error. Yet when I disable the plugin and refresh the very same page, it does work.
The browser error is that the page incorrectly redirects in a way that will never end...
Last edited by TheVigilante on Fri Nov 02, 2007 2:46 pm, edited 1 time in total.
-
- Joomla! Apprentice
- Posts: 6
- Joined: Tue Sep 11, 2007 8:24 am
Re: Plugin question
I think I already see what goes wrong. When the redirect is done, the plugin will be called again and redirects again etc, etc.
So I guess I got it solved!
So I guess I got it solved!
Re: Plugin question
TheVigilante wrote:I think I already see what goes wrong. When the redirect is done, the plugin will be called again and redirects again etc, etc.
So I guess I got it solved!
My first thought would be using a static variable. Can you explain how you got it solved please?
My Joomla! 1.5 extensions - http://joomla.ercan.us
Progress is made by lazy men looking for easier ways to do things.
Progress is made by lazy men looking for easier ways to do things.
-
- Joomla! Apprentice
- Posts: 6
- Joined: Tue Sep 11, 2007 8:24 am
Re: Plugin question
The plugin I'm trying to create works differently, this was just a test. Because of the redirect error I thought something didn't work, but now that I know it keeps executing the same redirect plugin over and over I know all works fine.