问题
I have developed a Joomla module that does provides a form, processes its post data, does some calculations and displays the results.
The module includes a button to print the results. I'm currently using JavaScript to open a new window, paste the relevant HTML and open the print dialog.
Instead of JavaScript I would prefer to provide a separate URL for the print view and simply open that in a _blank target. This would make the application work better for people using screen readers or not having JavaScript available.
Is there any way that I can tell Joomla to not render the template along with my module? I was thinking that creating a component fixes that issue, but had to find that components are rendered into the template, too...
BTW: I have Joomla 1.5.22
回答1:
To achieve what you want you have to add additional tmpl=component
query string parameter to the request URL. This will disable template and module rendering.
Your URL will look something like this: index.php?option=com_xxx&view=xxx&tmpl=component
Since you are using Joomla 1.5 you can request index2.php?option=com_xxx&view=xxx
and it will only render the component. Joomla 2.5 does not have index2.php
so if you plan to migrate in future, don't use this option.
If you are using SEF then adding ?tmpl=component
at the end on URL does the trick.
To go a step deeper... in your template directory you have
component.php
file, that is the file that's being loaded by tmpl
param. You can copy component.php
to my_component.php
, do necessary changes and load your custom component template with index.php?option=com_xxx&view=xxx&tmpl=my_component
回答2:
The joomla way of doing it would be to set your output to "raw", see this tut:
http://www.katcode.com/displaying-raw-output-in-joomla-by-setting-format-in-the-component/
来源:https://stackoverflow.com/questions/10248080/joomla-module-or-component-to-be-render-on-a-blank-page