Page 1 of 1

Skip Template Rendering

Posted: Sun Nov 18, 2007 11:30 am
by dinochopins
Hi All,

I'm developing a component's page which I don't want to have any template attach to it. But still can be called using

index.php?option=com_component¶m1=value1.....

How can I do that ?

Regards,

Dino

Re: Skip Template Rendering

Posted: Sun Nov 18, 2007 1:37 pm
by MMMedia
Moving this thread to the Coding 101 forum.

Re: Skip Template Rendering

Posted: Wed Dec 05, 2007 10:10 pm
by kdevine
I have found two options:

1. Create a raw view - view.raw.php
This will only render out put from your view but will not load any info in the document head. It's a good option for doing anything with Ajax.

2. Add tmpl=component in the URL query
This will load head info, along with your template css, but will only output your view in the document body. The email a friend icon uses this for the email form pop up window.

Anybody know another/better way to do this?

Re: Skip Template Rendering

Posted: Fri Dec 07, 2007 6:22 pm
by lobos
You just need to add exit() or die() after component processing is completed.

for example - mycomponent.php


echo 'helloworld';

die();

?>

Your component will be process within joomla and no templates or modules will be processed or rendered.

-Lobos

Re: Skip Template Rendering

Posted: Fri Dec 07, 2007 8:29 pm
by kdevine
Yes this will keep Joomla from rendering your component output in a template. However the resulting output will not be an actual HTML document either. This will also kill all Joomla processes following the document rendering - caching as well as several other events such as onAfterDispatch and onAfterRender which are used to execute plugins. You also lose the ability to do this variably. I would not recommend this method.

Re: Skip Template Rendering

Posted: Fri Dec 07, 2007 9:48 pm
by mtlnews
I was also building a component where I don't need the template to be rendered always. In the view where I don't need it, I don't call the "parent::display($tpl);" function your supposed to call. Does this keep my template from being rendered?

Re: Skip Template Rendering

Posted: Fri Dec 07, 2007 10:07 pm
by kdevine
parent::display($tpl) loads the template of your view not the template of your site. If you do not call that display function anywhere in your view Joomla will not render any output from your component but it will still load the template of your site.

Re: Skip Template Rendering

Posted: Fri Dec 07, 2007 10:14 pm
by mtlnews
i see... my code is a couple short lines though: I get what I need from the model and then I just print it out:

Code: Select all

   $xml   = $this->get( 'XML' );
   $page   = & JFactory::getDocument();
   $page->setMimeEncoding( 'text/xml' );
   JResponse::setHeader( 'Content-Disposition', 'inline; filename=xml.xml' );
   echo $xml;


so, the only way to just render this without wasting time and energy would be to call the 'view' file view.raw.php?

Re: Skip Template Rendering

Posted: Fri Dec 07, 2007 10:21 pm
by kdevine
Not the only way but yes I would recommend using the raw format in your case. You only need two things.
1. In the URL linking to this, add "format=raw" as a variable in the URL query
2. Save this view file as view.raw.php

That's it.

Re: Skip Template Rendering

Posted: Fri Dec 07, 2007 10:39 pm
by mtlnews
thx a lot, i will try that