Hallo,
ich schreibe gerade eine Extension und stehe vor einem schwerwiegenden (zumindest für mich 😃) Problem.
Es geht darum, dass ich im PHP Code meiner Extension die FCE von Produktseiten auslesen will (da stehen technische Daten drin), die ich dann weiterverarbeiten möchte.
Zu diesem Zweck gibt es auch eine User_func. Am liebsten würde ich diese gerne verwenden um z.B. die technischen Daten der Seite mit ID 65 in einem Array zurückzubekommen.
Geht das vielleicht über folgende User_func? Wenn ja, welche Parameter müsste ich übergeben? :S
Notfalllösungen für mich wären 1. tt_content Tabelle anzapfen und die FCE daraus aufwändig parsen oder 2. die Seiten so aufrufen und den HTML Code parsen, was beides nicht wirklich schön wäre.
<?php
require_once(PATH_tslib.'class.tslib_pibase.php');
class user_tx_templavoila_flex_get extends tslib_pibase {
function field($content,$conf) {
$tx_templavoila_flex_array = t3lib_div::xml2array($this->cObj->data['tx_templavoila_flex']);
$content = $this->pi_getFFvalue($tx_templavoila_flex_array,$conf['flex_data']);
return $content;
}
function technischedaten($content,$conf) {
$tx_templavoila_flex_array = t3lib_div::xml2array($this->cObj->data['tx_templavoila_flex']);
if (is_array($tx_templavoila_flex_array))
{
$sections = $tx_templavoila_flex_array['data']['sDEF']['lDEF']['field_technischedaten']['el'];
if (is_array($sections))
{
foreach($sections as $section)
{
$content = $content.'<p>'.'<span>'.$section['field_technischesdatum']['el']['field_attribut']['vDEF'].'</span>';
$content = $content.'<span style="float:right;font-size:11px;margin-left:15px;margin-top:1px;">'.$section['field_technischesdatum']['el']['field_wert']['vDEF'].'</span>'.'</p>';
}
}
if (!empty($content))
{
$content = '<div style="margin-top:15px;">'.$content.'</div>';
}
}
return $content;
}
Könnt ihr mir da helfen?
Die Tooltip Funktion (wurde damals über TS realisiert), die die Technischen Daten als Tooltip ausgibt, sieht folgendermaßen aus.
page.10.marks.MIDDLE = COA
page.10.marks.MIDDLE {
stdWrap.prepend = COA
stdWrap.prepend {
10 = TEXT
10.value = <div id="middle"
20 = TEXT
20.if.isTrue.cObject < styles.content.getRight
20.noTrimWrap = | ||
20.value = class="andright"
30 = TEXT
30.value = >
}
wrap = |</div>
10 = HMENU
10 {
includeNotInMenu = 1
special = rootline
special.range = 1|-1
wrap = <div class="ariadne">|</div>
1 = TMENU
1 {
noBlur = 1
CUR = 1
CUR.doNotLinkIt = 1
NO.linkWrap = | >
}
}
20 < styles.content.get
}
[globalVar = TSFE:page|pid = 4]
page.includeJS.file1 = fileadmin/templates/holger-clasen/js/tooltip.js
page.10.marks.MIDDLE.30 = HMENU
page.10.marks.MIDDLE.30 {
special = directory
stdWrap.split {
cObjNum = 1 || 2 || 3
token = ###SPLIT1###
1.current = 1
2.current = 1
2.split {
cObjNum = 1 || 1 || 2 || 2 || 2 |*| 3 || 4 || 4 || 4
token = ###SPLIT2###
1.current = 1
2.current = 1
2.noTrimWrap = | border-left|
3.current = 1
3.noTrimWrap = | border-top|
4.current = 1
4.noTrimWrap = | border-leftandtop|
}
3 < .2
3.noTrimWrap = | margin-top|
}
1 = TMENU
1 {
noBlur = 1
NO {
allWrap = <div class="Produktvorschau###SPLIT2###" onmouseover="XBT(this,{id:'tooltip{elementUid}'})">|</div>
doNotLinkIt = 1
stdWrap.cObject = CONTENT
stdWrap.cObject {
renderObj = COA
renderObj {
10 = IMAGE
10 {
file = GIFBUILDER
file {
XY = 170,115
10 = IMAGE
10.align = c,c
10.file {
height = 115m
import.cObject = USER
import.cObject {
flex_data = field_multimedia
userFunc = user_tx_templavoila_flex_get->field
}
import.ifEmpty.cObject = CONTENT
import.ifEmpty.cObject {
renderObj = USER
renderObj {
flex_data = field_multimedia
userFunc = user_tx_templavoila_flex_get->field
}
select {
pidInList.field = pid
uidInList.field = t3_origuid
}
table = tt_content
}
import.listNum = 0
import.wrap = uploads/tx_templavoila/
width = 170m
}
}
stdWrap.typolink.parameter.field = pid
}
20 = TEXT
20.value = <br />
30 = TEXT
30.field = header
30.typolink.parameter.field = pid
40 = COA
40 {
wrap = <div id="tooltip{elementUid}" style="background-color:#00265C;color:#FFFFFF;display:none;max-width:245px;padding:5px;">|</div>
10 = TEXT
10.field = header
10.wrap = <b>|</b>
20 = USER
20 {
userFunc = user_tx_templavoila_flex_get->technischedaten
}
}
}
select {
languageField = sys_language_uid
max = 1
pidInList.data = field:uid
pidInList.data.override = field:shortcut
pidInList.data.override.if.isTrue.data = field:shortcut
}
table = tt_content
}
subst_elementUid = 1
}
SPC = 1
SPC.allWrap = <div class="clear"></div><div class="Produktkategorie###SPLIT1###"><h1><a id="uid{field:uid}">|</a></h1></div>
SPC.allWrap.insertData = 1
}
}
}
[global]
[globalVar = TSFE:page|pid = 4] AND [globalVar = GP:L = 1]
page.10.marks.MIDDLE.30.1.NO.stdWrap.cObject.select {
languageField >
orderBy = sys_language_uid DESC
}
[global]
Der Plugin Code sieht bisher so aus:
class tx_werkzeugauswahl_pi1 extends tslib_pibase {
public $prefixId = 'tx_werkzeugauswahl_pi1'; // Same as class name
public $scriptRelPath = 'pi1/class.tx_werkzeugauswahl_pi1.php'; // Path to this script relative to the extension dir.
public $extKey = 'werkzeugauswahl'; // The extension key.
/**
* The main method of the Plugin.
*
* @param string $content The Plugin content
* @param array $conf The Plugin configuration
* @return string The content that is displayed on the website
*/
public function main($content, array $conf) {
$this->conf = $conf;
$this->pi_setPiVarDefaults();
$this->pi_loadLL();
$this->pi_USER_INT_obj = 1; // Configuring so caching is not expected. This value means that no cHash params are ever set. We do this, because it's a USER_INT object!
$content = '
<strong>This is a few paragraphs:</strong><br />
<p>This is line 1</p>
<p>This is line 2</p>
<h3>This is a form:</h3>
<form action="' . $this->pi_getPageLink($GLOBALS['TSFE']->id) . '" method="POST">
<input type="text" name="' . $this->prefixId . '[input_field]" value="' . htmlspecialchars($this->piVars['input_field']) . '" />
<input type="submit" name="' . $this->prefixId . '[submit_button]" value="' . htmlspecialchars($this->pi_getLL('submit_button_label')) . '" />
</form>
<br />
<p>You can click here to ' . $this->pi_linkToPage('get to this page again', $GLOBALS['TSFE']->id) . '</p>
';
$content.=$this->pi_linkToPage($GLOBALS['TSFE']->page['title'],$GLOBALS['TSFE']->id);
t3lib_div::debug($this->piVars,'Test debug');
t3lib_div::debug($this->conf,'Test debug 2');
return $this->pi_wrapInBaseClass($content);
}
}
if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/werkzeugauswahl/pi1/class.tx_werkzeugauswahl_pi1.php'])) {
include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/werkzeugauswahl/pi1/class.tx_werkzeugauswahl_pi1.php']);
}
?>
In PHP kenne ich mich soweit aus, Typo3 ist finde ich nur relativ speziell...
Ich freue mich auf eure Hilfe!! Bin total am verzweifeln 🙁