Ich hab von der site
http://docs.joomla.org/Make_changes_...using_a_plugin
folgendes Beispielplugin geladen
die xml Datei DazuPHP-Code:<?php
/**
* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
*/
// Check to ensure this file is included in Joomla!
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport( 'joomla.plugin.plugin' );
class plgContentModifyArticle extends JPlugin
{
/**
* Constructor
*
* For php4 compatability we must not use the __constructor as a constructor for plugins
* because func_get_args ( void ) returns a copy of all passed arguments NOT references.
* This causes problems with cross-referencing necessary for the observer design pattern.
*
* @param object $subject The object to observe
* @param object $params The object that holds the plugin parameters
* @since 1.5
*/
function plgContentModifyArticle ( &$subject, $params )
{
parent::__construct( $subject, $params );
}
/**
* Example before save content method
*
* Method is called right before content is saved into the database.
* Article object is passed by reference, so any changes will be saved!
* NOTE: Returning false will abort the save with an error.
* You can set the error by calling $article->setError($message)
*
* @param object A JTableContent object
* @param bool If the content is just about to be created
* @return bool If false, abort the save
*/
function onBeforeContentSave( &$article, $isNew )
{
global $mainframe;
$newText = '<p>This is my new text to add to the article.</p>';
$user =& JFactory::getUser(); // get the user
if ($user->usertype == 'Author') {
if ($article->fulltext) {
if (strpos($article->fulltext, $newText) == 0) {
$article->fulltext .= $newText;
}
}
else {
if (strpos($article->introtext, $newText) == 0) {
$article->introtext .= $newText;
}
}
}
return true;
}
}
?>
Wenn ich jetzt einen Artikel aufrufe und danach speichere sollte doch an sichCode:<?xml version="1.0" encoding="utf-8"?> <install version="1.5" type="plugin" group="content"> <name>Modify Edited Articles</name> <creationDate>January 2009</creationDate> <author>Joomla Doc Team</author> <authorEmail>myemail@myemail.com</authorEmail> <authorUrl>http://joomlacode.org</authorUrl> <copyright>Copyright (c) 2009</copyright> <license>GPL</license> <version>1.0.0</version> <description>Example plugin for Joomla! wiki.</description> <files> <filename plugin="modifyarticle">modifyarticle.php</filename> </files> </install>
This is my new text to add to the article.
am Ende eines Artikels stehen. Geht aber nicht
![]()


LinkBack URL
About LinkBacks
Zitieren
Lesezeichen