Skip Template Rendering Topic is solved

Discussion and education for beginner / novice programmers interested in embarking on the development process to take advantage of the extensible nature of the Joomla! CMS.

Moderators: tjay, seadap, Rogue4ngel, matthewhayashida

Forum rules
Post Reply
dinochopins

Skip Template Rendering

Post by dinochopins » Sun Nov 18, 2007 11:30 am

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

User avatar
MMMedia
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 233
Joined: Sun Aug 21, 2005 2:25 pm
Location: Somewhere Near Here

Re: Skip Template Rendering

Post by MMMedia » Sun Nov 18, 2007 1:37 pm

Moving this thread to the Coding 101 forum.
Be kinder than necessary, for everyone you meet is fighting some kind of battle.
http://www.oddsheepout.com http://www.jennifermarriott.com
JOOMLA ROCKS
Women JOOMLA! Too

kdevine
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Thu Mar 02, 2006 8:38 pm
Location: Baltimore, MD

Re: Skip Template Rendering

Post by kdevine » Wed Dec 05, 2007 10:10 pm

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?

User avatar
lobos
Joomla! Apprentice
Joomla! Apprentice
Posts: 30
Joined: Wed Jul 19, 2006 3:33 pm
Location: Sao Paulo, Brasil
Contact:

Re: Skip Template Rendering

Post by lobos » Fri Dec 07, 2007 6:22 pm

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
Respect and honour, sempre isso, the tribal way, the only way.
http://en.wikipedia.org/wiki/Tribes_Vengeance

kdevine
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Thu Mar 02, 2006 8:38 pm
Location: Baltimore, MD

Re: Skip Template Rendering

Post by kdevine » Fri Dec 07, 2007 8:29 pm

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.

mtlnews

Re: Skip Template Rendering

Post by mtlnews » Fri Dec 07, 2007 9:48 pm

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?

kdevine
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Thu Mar 02, 2006 8:38 pm
Location: Baltimore, MD

Re: Skip Template Rendering

Post by kdevine » Fri Dec 07, 2007 10:07 pm

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.

mtlnews

Re: Skip Template Rendering

Post by mtlnews » Fri Dec 07, 2007 10:14 pm

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?

kdevine
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Thu Mar 02, 2006 8:38 pm
Location: Baltimore, MD

Re: Skip Template Rendering

Post by kdevine » Fri Dec 07, 2007 10:21 pm

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.

mtlnews

Re: Skip Template Rendering

Post by mtlnews » Fri Dec 07, 2007 10:39 pm

thx a lot, i will try that


Post Reply