2016-07-01 3 views
1

私はちょうどJoomlaを学び始めました。 onAfterInitialise()イベントの使い方を教えてください.Joomlaプラグインを使ってどのように動作するかを見たいだけです。今のところ私はちょうどページがこのプラグインでロードされたときに、ホームページまたはすべてのページに 'Some text'を表示したいと思います。joomlaのホームページ上にテキストを表示する方法onAfterInitialise()joomlaで3x

オンラインのチュートリアルの助けを借りて、プラグインを作成してインストールして起動しました。それをどうやって使うのか分かりません!

XMLファイルchat.xml PHPファイルchat.php

<?php 
// no direct access 
defined('_JEXEC') or die; 
jimport('joomla.plugin.plugin'); 

class plgSystemChat extends JPlugin 
{ 

    public function __construct(&$subject, $config) 
    { 
     parent::__construct($subject, $config); 

    } 

    protected $autoloadLanguage = true; 

    function onAfterInitialise() 
    { 
     echo "<h1>test plgContentConversekit</h1>"; 
     return true; 
    } 
} 
?> 

し、その中に次のコードを持つindex.html

<?xml version="1.0" encoding="utf-8"?> 
<extension version="3.1" type="plugin" group="System"> 
    <name>Chat</name> 
    <author>Apple</author> 
    <creationDate>November 2005</creationDate> 
    <copyright>Copyright (C) 2016 mysite.com.</copyright> 
    <license>GNU General Public License version 2 or later; see LICENSE.txt</license> 
    <authorEmail>[email protected]</authorEmail> 
    <authorUrl>www.mysite.com</authorUrl> 
    <version>3.1.0</version> 
    <description>This is a chatting plugin</description> 
    <files> 
     <filename plugin="categories">chat.php</filename> 
     <filename>index.html</filename> 
    </files> 
</extension> 

<!DOCTYPE html><title></title> 
+0

ワードプレスの背景から来ていますか? Wordpressのプラグインは、Joomlaのプラグインとは異なります。 –

答えて

0

私はonAfterInitialiseを利用する方法を発見しました() 。以下では、スクリプトとスタイルシートをページの読み込みに追加するために使用しました。

function onAfterInitialise() { 

     // Load Bootstrap 
     JHtml::_('jquery.framework'); 
     JHtml::_('bootstrap.framework'); 
     $document = JFactory::getDocument(); 
     $document->addStyleSheet(JURI::base(). "plugins/system/conversekit/conversekit.css"); 
     $document->addScript("plugins/system/conversekit/conversekit.js", "text/javascript", false, false); 

     return true; 
    } 
関連する問題