При создании своего расширения нужно составить список категорий новостей.
Это простая задача, если не брать во внимание подкатегории.
Для учета подкатегорий решил подключить класс class.tx_ttnews.php и заюзать полезную функцию initCategoryVars:
PHP код:
<?php
/***************************************************************
* Copyright notice
*
* (c) 2011
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* [CLASS/FUNCTION INDEX of SCRIPT]
*
* Hint: use extdeveval to insert/update function index above.
*/
require_once(PATH_tslib.'class.tslib_pibase.php');
require_once(t3lib_extMgm::extPath('tt_news') . 'pi/class.tx_ttnews.php');
/**
* Plugin 'tt_news_change_picture' for the 'tt_news_change_image' extension.
*
* @author
* @package TYPO3
* @subpackage tx_ttnewschangeimage
*/
class tx_ttnewschangeimage_pi1 extends tslib_pibase {
var $prefixId = 'tx_ttnewschangeimage_pi1'; // Same as class name
var $scriptRelPath = 'pi1/class.tx_ttnewschangeimage_pi1.php'; // Path to this script relative to the extension dir.
var $extKey = 'tt_news_change_image'; // The extension key.
var $pi_checkCHash = true;
var $cObj; // The backReference to the mother cObj object set at call time
/**
* The main method of the PlugIn
*
* @param string $content: The PlugIn content
* @param array $conf: The PlugIn configuration
* @return The content that is displayed on the website
*/
function main($content, $conf) {
$this->cObj=t3lib_div::makeInstance('tslib_cObj');
$this->conf = $conf;
$this->pi_loadLL(); // Loading language-labels
$this->pi_setPiVarDefaults(); // Set default piVars from TS
$this->pi_initPIflexForm(); // Init FlexForm configuration for plugin
$tt_news = new tx_ttnews;
$tx_news->cObj = t3lib_div::makeInstance('tslib_cObj');
$tt_news->enableFields = $tx_news->cObj->enableFields('tt_news');
// initialize category vars
$tt_news->initCategoryVars(); <-эта строка вызывает ошибку
$content='';
return $this->pi_wrapInBaseClass($content);
}
}
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/tt_news_change_image/pi1/class.tx_ttnewschangeimage_pi1.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/tt_news_change_image/pi1/class.tx_ttnewschangeimage_pi1.php']);
}
?>
это вызывает ошибку:
Код HTML:
Fatal error: Call to a member function enableFields() on a non-object in /usr/local/apache2/htdocs/..мой сайт../typo3conf/ext/tt_news/pi/class.tx_ttnews.php on line 2730
Вызвано это тем что в class.tx_ttnews.php данная функция enableFields вызывается таким образом:
PHP код:
код расширения tt_news
$this->enableCatFields = $this->cObj->enableFields('tt_news_cat');
Получается что родительский объект cObj не инициализируется, хотя я явно задал его?
Я слабо разбираюсь в особенностях объектного программирования в php.