简体   繁体   English

Joomla:如何将PHP / HTML文件发布到模块位置

[英]Joomla : how to publish a PHP / HTML file to a Module Position

I am looking for a solution to publish a PHP / HTML file to a Joomla Module position. 我正在寻找一种将PHP / HTML文件发布到Joomla模块位置的解决方案。 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文件是这样的:

<?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. 该脚本的作用是........它转换此文件的输出并将其保存为静态HTML格式。 Now I want to publish this HTML file to a given module position. 现在,我想将此HTML文件发布到给定的模块位置。 How can I do so? 我该怎么办?

Kindly help. 请帮助。

try using this module: http://www.joomlaos.de/Joomla_CMS_Downloads/Joomla_Plugins/includePHP.html 尝试使用此模块: 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 在您的模块中,或者将您的代码排除在外部php文件中,然后执行类似的操作

{phpfile} /home/mysite/public_html/mycode.php {/phpfile}

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. 最简单的方法是创建一个模块,因为您没有数据库连接,只需复制任何现有模块即可更改文件名,然后在XML文件中将代码放入主文件中就可以了。

Example: 例:

mod_static/mod_static.php 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 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 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. 这就是您所需要的,然后将所有文件放在modules目录中,并通过Joomla将模块分配到适当的位置。 Good luck! 祝好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM