setredirect from view.html.php

For Joomla! 1.5 Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general
Forum rules
Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.
Locked
User avatar
malaiselvan
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 161
Joined: Mon Dec 08, 2008 10:57 am
Contact:

setredirect from view.html.php

Post by malaiselvan » Wed Jul 28, 2010 4:11 pm

Hi,

I have a link in one of my view. If a unregistered user clicks on the link I want to redirect him to the joomla login page.

I tried the setredirect in my view.html.php and it throws Fatal error: Call to undefined method error.

Any idea how this can be done.

Thanks & Regards
Malai
www.joomalai.co.in, www.jeema.net
Your Joomla Specialist from Chennai, India

User avatar
sullendreams
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Thu Jul 29, 2010 6:53 am

Re: setredirect from view.html.php

Post by sullendreams » Thu Jul 29, 2010 6:59 am

Setredirect is only in the controller class, not the view class. Thus Joomla was designed so you should be redirecting from the controller and not the view. (If you are in the view class you have already decided to use the specific view and are rendering it!) However you can accomplish this by bringing in the JApplication instance and redirecting as shown:

Code: Select all

$app =& JFactory::getApplication();
$app->redirect('index.php?option=com_user&view=login');
cheers,
sd

User avatar
malaiselvan
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 161
Joined: Mon Dec 08, 2008 10:57 am
Contact:

Re: setredirect from view.html.php

Post by malaiselvan » Thu Jul 29, 2010 12:34 pm

Thanks man. Its working now.

Cheers
Malai
www.joomalai.co.in, www.jeema.net
Your Joomla Specialist from Chennai, India

Laurij
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Fri Jan 29, 2010 8:13 am

Re: setredirect from view.html.php

Post by Laurij » Fri Apr 20, 2012 7:38 am

I know this is an old post, but still Thanks!

I needed a way to forward from listing view to a single item view when only one item is listed. Sort of shortcut. This fit the need perfectly.

jinald
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Wed Aug 08, 2012 7:25 am
Location: Ahmedabad,India
Contact:

Re: setredirect from view.html.php

Post by jinald » Wed Aug 08, 2012 7:27 am

It's work for me Thanks a ton. :)


Locked

Return to “Joomla! 1.5 Coding”