Hallo, ich doktere seit ein paar Stunden an einem mir nicht erklärlichen Problem herum:
Mein PlugIn fügt com_content ein paar Felder hinzu, die Definition der Felder liegt in der Datei extras/eventparams.xml:
XML
<?xml version="1.0" encoding="utf-8" ?>
<form>
<fields name="attribs" addrulepath="/plugins/content/eventlist/models/rules">
<fieldset name="eventinfo" label="PLG_CONTENT_EVENTLIST_FIELDSET_EVENTINFO">
...
<field
name="eventlist_weekday"
type="list"
label="PLG_CONTENT_EVENTLIST_PARAM_WEEKDAY"
description="PLG_CONTENT_EVENTLIST_PARAM_WEEKDAY_DESC"
>
<option value=""></option>
<option value="1">PLG_CONTENT_EVENTLIST_VALUE_SUNDAY</option>
<option value="2">PLG_CONTENT_EVENTLIST_VALUE_MONDAY</option>
<option value="3">PLG_CONTENT_EVENTLIST_VALUE_TUESDAY</option>
<option value="4">PLG_CONTENT_EVENTLIST_VALUE_WEDNESDAY</option>
<option value="5">PLG_CONTENT_EVENTLIST_VALUE_THURSDAY</option>
<option value="6">PLG_CONTENT_EVENTLIST_VALUE_FRIDAY</option>
<option value="7">PLG_CONTENT_EVENTLIST_VALUE_SATURDAY</option>
</field>
...
</fieldset>
</fields>
</form>
Alles anzeigen
Nun will ich in der Funktion onContentPrepare auf die Werte in den Optionsfeldern des Feldes "eventlist_weekday" zugreifen, um dann über JText den lokalen Wochentagnamen ausgeben zu können. Dazu mache ich folgendes:
Code
public function onContentPrepare($context, &$article, &$params, $page = 0)
{
...
// Construct a result table on the fly
jimport('joomla.html.grid');
$table = new JGrid();
// Create columns
$table->addColumn('attr')->addColumn('value');
// Load form & fieldset
$form = JForm::getInstance('eventparams', dirname(__FILE__) . '/extras/eventparams.xml');
$fieldSet = $form->getFieldSet('eventinfo');
// Populate
$rownr = 0;
foreach ($eventdata as $attr => $value)
{
$table->addRow(array('class' => 'row'.($rownr % 2)));
// Get the field's local label and the local weekday string
$label = "";
$weekday = "";
foreach ($fieldSet as $field) {
...
if ($field->getAttribute('name') == 'eventlist_weekday') {
$optionFields = $field->__get('element');
...
}
}
...
}
...
}
Alles anzeigen
Leider liefert mir die Abfrage $field->__get('element') nur NULL zurück, obwohl var_dump folgende Ausgabe für $field liefert und eine ähnliche Abfrage wie $field->__get('type') wunderbar funktioniert:
Code
object(JFormFieldList)#640 (38) {
["type":protected]=> string(4) "List"
["description":protected]=> string(40) "PLG_CONTENT_EVENTLIST_PARAM_WEEKDAY_DESC"
["hint":protected]=> string(0) ""
["autocomplete":protected]=> string(2) "on"
["spellcheck":protected]=> bool(true)
["autofocus":protected]=> bool(false)
["element":protected]=> object(SimpleXMLElement)#630 (2) {
["@attributes"]=> array(4) {
["name"]=> string(17) "eventlist_weekday"
["type"]=> string(4) "list"
["label"]=> string(35) "PLG_CONTENT_EVENTLIST_PARAM_WEEKDAY"
["description"]=> string(40) "PLG_CONTENT_EVENTLIST_PARAM_WEEKDAY_DESC"
}
["option"]=> array(8) {
[0]=> object(SimpleXMLElement)#645 (1) {
["@attributes"]=> array(1) {
["value"]=> string(0) ""
}
}
[1]=> string(34) "PLG_CONTENT_EVENTLIST_VALUE_SUNDAY"
[2]=> string(34) "PLG_CONTENT_EVENTLIST_VALUE_MONDAY"
[3]=> string(35) "PLG_CONTENT_EVENTLIST_VALUE_TUESDAY"
[4]=> string(37) "PLG_CONTENT_EVENTLIST_VALUE_WEDNESDAY"
[5]=> string(36) "PLG_CONTENT_EVENTLIST_VALUE_THURSDAY"
[6]=> string(34) "PLG_CONTENT_EVENTLIST_VALUE_FRIDAY"
[7]=> string(36) "PLG_CONTENT_EVENTLIST_VALUE_SATURDAY"
}
}
...
Alles anzeigen
Frage: Wie komme ich an die "options" in meinem "element"?
Vielen Dank!