help on $mainframe

Joomla! Documentation Workgroup

Moderator: Documentation

Locked
rajup
Joomla! Apprentice
Joomla! Apprentice
Posts: 31
Joined: Thu Aug 20, 2009 9:24 am

help on $mainframe

Post by rajup » Tue Sep 22, 2009 12:12 pm

I want to know how to use globle variable like $mainframe in project.

I used one statement like $mainframe->redirect('http://myurl.com')

It is not working and its giving error as follow:

Fatal error: Call to a member function redirect() on a non-object in /var/www/joomla/administrator/components/com_mail/admin.mail.php on line 29

is it required any type of declaration of globle variable ??

Please help me..

Thanks.
Last edited by rajup on Wed Sep 23, 2009 3:32 am, edited 1 time in total.

User avatar
Chris Davenport
Joomla! Ace
Joomla! Ace
Posts: 1370
Joined: Thu Aug 18, 2005 8:57 am
Location: Shrewsbury, Shropshire, United Kingdom

Re: help on $mainframe

Post by Chris Davenport » Tue Sep 22, 2009 2:04 pm

You should use the JFactory object instead of globals. Try:

Code: Select all

$app =& JFactory::getApplication();
$app->redirect( <url> );
Chris.
Chris Davenport

Davenport Technology Services http://www.davenporttechnology.com/
Lion Coppice http://www.lioncoppice.org/

rajup
Joomla! Apprentice
Joomla! Apprentice
Posts: 31
Joined: Thu Aug 20, 2009 9:24 am

Re: help on $mainframe

Post by rajup » Wed Sep 23, 2009 3:41 am

oh great ! :) that worked perfectly as I wanted !!!!!!!

But please let me know how to use global var like $mainframe etc. as I am keen to learn joomla. ???

User avatar
Chris Davenport
Joomla! Ace
Joomla! Ace
Posts: 1370
Joined: Thu Aug 18, 2005 8:57 am
Location: Shrewsbury, Shropshire, United Kingdom

Re: help on $mainframe

Post by Chris Davenport » Wed Sep 23, 2009 7:49 am

The use of global variables is being deprecated, so you should avoid using them.

Chris.
Chris Davenport

Davenport Technology Services http://www.davenporttechnology.com/
Lion Coppice http://www.lioncoppice.org/

User avatar
Lara_Shadow
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 228
Joined: Thu Jul 30, 2009 12:39 pm
Location: INDIA

Re: help on $mainframe

Post by Lara_Shadow » Thu Oct 08, 2009 2:17 pm

I want to know about $mainframe.

Where it is defined?
What information does it contains?
Why we need it?


Locked

Return to “docs.joomla.org - Feedback/Information”