Reputation: 1078
I am looking for a solution to publish a PHP / HTML file to a Joomla Module position. This is not a Module but is a part of additional features of my template. Hence I don't want to convert it into a Module.
My php File is something like this:
<?php
<--Some functions here -->
ob_start();
<-- Some php code here -->
$contents = ob_get_clean();
$fp = fopen('hallo.html', 'w') or die('couldn\'t open file for writing.');
fwrite($fp, $contents);
fclose($fp);
?>
What this script does is........ It converts the output of this file and saves it in a Static HTML format. Now I want to publish this HTML file to a given module position. How can I do so?
Kindly help.
Upvotes: 0
Views: 1914
Reputation: 25254
try using this module: http://www.joomlaos.de/Joomla_CMS_Downloads/Joomla_Plugins/includePHP.html
after installing simply:
{php} echo 'this is code'; {/php}
in your module, or exlude your code in an external php file and do something like
{phpfile} /home/mysite/public_html/mycode.php {/phpfile}
Upvotes: 2
Reputation: 10015
The easiest way would be to create a module, since you have no database connection just copy any of existing modules change the names of the files and in the XML file place the code in the main file and you are ready.
Example:
mod_static/mod_static.php
<?php
// no direct access
defined('_JEXEC') or die('Restricted access');
// Include the syndicate functions only once
require_once(dirname(__FILE__).DS.'helper.php');
// Initialize the helper class
$helper = new modStaticHelper($params);
// Your PHP code here, any functions and data manipulations
require(JModuleHelper::getLayoutPath('mod_static'));
mod_static/mod_static.xml
<?xml version="1.0" encoding="utf-8"?>
<install type="module" version="1.5.0">
<name>mod_static</name>
<author>mod_static</author>
<creationDate>December 2010</creationDate>
<copyright></copyright>
<license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
<authorEmail></authorEmail>
<authorUrl></authorUrl>
<version>0.5b</version>
<description></description>
<files>
<filename module="mod_static">mod_static.php</filename>
</files>
<params>
</params>
</install>
mod_static/tmpl/default.php
<?php // no direct access
defined('_JEXEC') or die('Restricted access'); ?>
<!-- Your HTML code and the ready PHP variables to echo here -->
That is all you need, after that just place all your files in the modules directory and assign the module through Joomla to appropriate position. Good luck!
Upvotes: 1