JDocument->getInstance('raw') not working as intended?

The support for Joomla 2.5 ended on December 31, 2014. Possible bugs in Joomla 2.5 will not be patched anymore. This forum has been closed. Please update your website to Joomla 3.x

Moderator: ooffick

Forum rules
Please use the official Bug Tracker to report a bug: https://issues.joomla.org
Locked
User avatar
Bakual
Joomla! Ace
Joomla! Ace
Posts: 1038
Joined: Sun Dec 13, 2009 9:00 pm
Location: Switzerland
Contact:

JDocument->getInstance('raw') not working as intended?

Post by Bakual » Wed Dec 22, 2010 10:09 pm

Not sure if this is intended behaviour or a bug.

In J1.5 we could use JDocument->getInstance('raw') in the component controller to force the document type to be "raw". This was nice in my case for making a podcast view.
In J1.6 this seems to no longer work. After calling it, Joomla will still search for view.html.php and not view.raw.php as expected.

I also tried with the function "JDocument->setType('raw')" but then it produces the error "Unable to load renderer class". So this seems to be not working as well.

The view is working when I add the parameter &format=raw to the URL. So the JDocumentRaw itself seems to be working.

Any thoughts?

User avatar
mcsmom
Joomla! Exemplar
Joomla! Exemplar
Posts: 7897
Joined: Thu Aug 18, 2005 8:43 pm
Location: New York
Contact:

Re: JDocument->getInstance('raw') not working as intended?

Post by mcsmom » Fri Dec 24, 2010 10:51 am

This might be useful for you:
http://docs.joomla.org/Xml-rpc

(It's really about all document types.)
So we must fix our vision not merely on the negative expulsion of war, but upon the positive affirmation of peace. MLK 1964.
http://officialjoomlabook.com Get it at http://www.joomla.org/joomla-press-official-books.html Buy a book, support Joomla!.

User avatar
Bakual
Joomla! Ace
Joomla! Ace
Posts: 1038
Joined: Sun Dec 13, 2009 9:00 pm
Location: Switzerland
Contact:

Re: JDocument->getInstance('raw') not working as intended?

Post by Bakual » Fri Dec 24, 2010 12:10 pm

Thanks for the link, it was an interesting read! But I think it doesn't answer my issue, or I miss something.

In J1.5 I could use the following code in my controller to force the document type "raw" for my 'feed' view:

Code: Select all

// Get the document object.
$document = JFactory::getDocument();

if (JRequest::getCmd('view') == 'feed' && (JRequest::getCmd('format') != 'raw')){ 
    // Changing the podcast format to raw output
    $document = $document->getInstance('raw');
}
This allowed me to catch the instance where one would call the view without the URL parameter '&format=raw'.
This no longer works in J1.6 for some reason. Joomla will not change the document type and thus creates an error because it can't find the view.html.php (which doesn't exists for this view). In J1.5 this code changed the document type and it looked for view.raw.php and everything was working fine.

I'm still not sure if this is a bug or how we could change a document type "on runtime" like we could in J1.5.

It's nothing gamebreaking. I still can just create a redirect to the same page with an added parameter '&format=raw'. But if there is a way to change it directly, it would be silly to reload the page :)

User avatar
oasisfleeting
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 114
Joined: Sun Jan 13, 2008 1:46 am
Contact:

Re: JDocument->getInstance('raw') not working as intended?

Post by oasisfleeting » Fri Jun 24, 2011 10:11 am

Maybe I misunderstand your problem, but if this is your component, can't you just add a view.raw.php view to your component and call it with
view index.php?option=mycomponent&format=raw
If I need a raw view, I just copy my view.html.php and rename it to view.raw.php

What i'm trying to do is get a raw output from the com_search component by adding the querystring format=raw without adding a view.raw.php file to the core com_search component.
Check out my joomla extensions at www.acoolsip.com

User avatar
Bakual
Joomla! Ace
Joomla! Ace
Posts: 1038
Joined: Sun Dec 13, 2009 9:00 pm
Location: Switzerland
Contact:

Re: JDocument->getInstance('raw') not working as intended?

Post by Bakual » Fri Jun 24, 2011 11:25 am

That's what I do. I have a view.raw.php in my view and it's working with the URL parameter &format=raw. But in Joomla 1.5 we could change the document type during runtime, which allowed to catch the case where a view is called without the URL parameter for various reasons (user error, simpler URL, ...). This seems to be no longer possible in J1.6.

Also your case will not be possible. &format=raw always needs a view.raw.php in the view directory or it will fail.
If you only want the output from the component without the modules, you could use &tmpl=component parameter.

User avatar
oasisfleeting
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 114
Joined: Sun Jan 13, 2008 1:46 am
Contact:

Re: JDocument->getInstance('raw') not working as intended?

Post by oasisfleeting » Fri Jun 24, 2011 7:03 pm

Bakual wrote:That's what I do. I have a view.raw.php in my view and it's working with the URL parameter &format=raw. But in Joomla 1.5 we could change the document type during runtime, which allowed to catch the case where a view is called without the URL parameter for various reasons (user error, simpler URL, ...). This seems to be no longer possible in J1.6.

Also your case will not be possible. &format=raw always needs a view.raw.php in the view directory or it will fail.
If you only want the output from the component without the modules, you could use &tmpl=component parameter.
I understand now. What about trying to force the raw view like this in the controller

Code: Select all

if (some case that turns out to be true){
    // Changing the podcast format to raw output
    JRequest::setVar('view','myview');
    JRequest::setVar('format','raw');
}
P.S. &tmpl=component is okay, but I still get a bunch of html like <body> and <head> and stuff like that so it's not gonna work for my purposes.
I read a blog post from the guy who wrote Tienda and NOixACL and they mention overriding any components controller using a plugin. If I can override the controller then I can definitely write and instance my own view and do it that way. I haven't quite figured out how they're doing it though.
Check out my joomla extensions at www.acoolsip.com

User avatar
Bakual
Joomla! Ace
Joomla! Ace
Posts: 1038
Joined: Sun Dec 13, 2009 9:00 pm
Location: Switzerland
Contact:

Re: JDocument->getInstance('raw') not working as intended?

Post by Bakual » Fri Jun 24, 2011 7:31 pm

I think I tried all the obvious stuff and it didn't work. It looks like the document is already set when Joomla loads the component controller.

User avatar
oasisfleeting
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 114
Joined: Sun Jan 13, 2008 1:46 am
Contact:

Re: JDocument->getInstance('raw') not working as intended?

Post by oasisfleeting » Fri Jun 24, 2011 7:56 pm

Bakual wrote:I think I tried all the obvious stuff and it didn't work. It looks like the document is already set when Joomla loads the component controller.
I did some testing and it looks like you're right about that. That totally sucks. The document shouldn't be set until the display() method is called in my opinion.
Check out my joomla extensions at www.acoolsip.com

User avatar
Bakual
Joomla! Ace
Joomla! Ace
Posts: 1038
Joined: Sun Dec 13, 2009 9:00 pm
Location: Switzerland
Contact:

Re: JDocument->getInstance('raw') not working as intended?

Post by Bakual » Fri Jun 24, 2011 8:13 pm

That's true.

hplugins
Joomla! Intern
Joomla! Intern
Posts: 56
Joined: Tue Aug 29, 2006 11:08 pm
Contact:

Re: JDocument->getInstance('raw') not working as intended?

Post by hplugins » Wed Aug 17, 2011 12:28 am

Did you ever find a Solution to this problem?
I'm experiencing the same problem with Joomla 1.7.

User avatar
Bakual
Joomla! Ace
Joomla! Ace
Posts: 1038
Joined: Sun Dec 13, 2009 9:00 pm
Location: Switzerland
Contact:

Re: JDocument->getInstance('raw') not working as intended?

Post by Bakual » Wed Aug 17, 2011 7:53 am

I did not find a solution itself. In just use a workaround in the controller and reload the page if &format=raw isn't passed for this particular view.

hplugins
Joomla! Intern
Joomla! Intern
Posts: 56
Joined: Tue Aug 29, 2006 11:08 pm
Contact:

Re: JDocument->getInstance('raw') not working as intended?

Post by hplugins » Wed Aug 17, 2011 1:25 pm

Thanks,
not pretty, but it will do for now.

User avatar
stutteringp0et
Joomla! Ace
Joomla! Ace
Posts: 1389
Joined: Sat Oct 28, 2006 11:16 pm
Location: Texas
Contact:

Re: JDocument->getInstance('raw') not working as intended?

Post by stutteringp0et » Thu Oct 13, 2011 11:58 pm

That sucks.

I'm running into the same problem, except I'm attempting to create a soapservice, so a redirect won't work for me. I'd rather not need to include format=raw, but there are already so many other get vars that I suppose one more won't matter.
My extensions: http://extensions.joomla.org/profile/pr ... ails/18398
Honk if this signature offends you.

yazoo
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Wed Feb 15, 2012 12:19 pm

Re: JDocument->getInstance('raw') not working as intended?

Post by yazoo » Wed Feb 15, 2012 12:47 pm

Hi guys,
I struggled with this problem and found a solution to the problem. It is quite simple actually and I hope it will help you. Here is the link to my post:

You'll have to remove the empty space (%20) between "blog" and "spot", the address is at [URL banned].com.

http://msmwebdev.[URL banned].com/2012/02/f ... oomla.html

BR


Locked

Return to “Joomla! 2.5 Bug Reporting”