[phpBB Debug] PHP Warning: in file [ROOT]/ext/tas2580/seourls/event/listener.php on line 213: Undefined array key "FORUM_NAME"
REDAXO Forum • rex::Property löschen
Seite 1 von 1

rex::Property löschen

Verfasst: 22. Mär 2017, 11:47
von beyben
na hi - in einem modul wird via rex::getProperty('tabs')->append(array[]) eine variable abgelegt. nun wuerde ich diese gerne nach der ausgabe loeschen, finde aber nicht heraus, wie man das macht.
ich will die module ein zweites mal auf einer seite nutzen, und muss nach der ersten ausgabe property 'tabs' leeren, sonst sind es bei der zweiten ausgabe alle & nicht nur die zweite haelfte:

tabs-eingabe
tabs-eingabe
tabs-ausgabe <- tabs loeschen
tabs-eingabe
tabs-ausgabe <- tabs loeschen

arbeite mit rex5, wie man sieht... hat jemand ne idee? ben

Re: rex::Property löschen

Verfasst: 22. Mär 2017, 11:50
von Oliver.Kreischer
Hej,

funktioniert
rex::setProperty(‘tabs’, '');
nicht?

LG
Oliver

Re: rex::Property löschen

Verfasst: 22. Mär 2017, 12:01
von beyben
leider nein, habe gestern auch rex::setProperty(‘tabs’,$leer); & co versucht. bei rex::setProperty(‘tabs’, ''); kommt:
Notice: Use of undefined constant ‘tabs’ - assumed '‘tabs’' in rex:///module/8/output on line 116
dachte auch vllt. rex::setProperty(‘tabs’)->unlink(); aber da is nix zu machen...
danke dir - ben

Re: rex::Property löschen

Verfasst: 22. Mär 2017, 12:21
von runstop64
Sieht aus, als ob das die falschen Anführungszeichen sind. Hast du den Code kopiert oder abgetippt?

Re: rex::Property löschen

Verfasst: 22. Mär 2017, 12:28
von Oliver.Kreischer
Hi,

versuche mal

Code: Alles auswählen

rex::removeProperty('tabs');
LG
Oliver

P.S.: Danke an Thomas für den Tipp (siehe Slack)!

Re: rex::Property löschen

Verfasst: 22. Mär 2017, 12:38
von beyben
na hei,
@runstop - ich habe alle anfuehrungszeichen ' " ` versucht...
@oli - da kommt:

Code: Alles auswählen

"ErrorException" thrown in rex:///module/7/output on line 10
Fatal error: Call to a member function append() on null
modul 7 ist die eingabe: rex::getProperty('tabs')->append($items);
ben

Re: rex::Property löschen

Verfasst: 22. Mär 2017, 12:49
von Oliver.Kreischer
Hi Ben,

da muss ich passen. Evtl. kann ich mir heute Abend (nach 20.00 Uhr) mal das Modul angucken wenn Du mich dran lässt :-)

LG
Oliver

Re: rex::Property löschen

Verfasst: 22. Mär 2017, 13:04
von Thomas.Blum
Hej,

sinnvoller wäre es, wenn du einmal deinen kompletten Modul-Code posten könntest.

vg Thomas

Re: rex::Property löschen

Verfasst: 22. Mär 2017, 14:04
von beyben
hi, endschuldigt. ist das accordion/tab modul der redaxo-demo:
07 . Akkordeon / Tabs (Eingabe)

Code: Alles auswählen

<!-- *******************************************************
TABS EINGABE
******************************************************** -->

<fieldset class="form-horizontal">
    <legend>Tabs Eingabe</legend>

    <div class="form-group">
        <label class="col-sm-2 control-label" for="headline">Icon</label>
        REX_MEDIA[id="1" widget="1"]
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label" for="headline">Überschrift</label>
        <div class="col-sm-10">
            <input class="form-control" id="headline" type="text" name="REX_INPUT_VALUE[2]" value="REX_VALUE[2]" />
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-2 control-label" for="markitup_textile_">Text</label>
        <div class="col-sm-10">
            <textarea cols="1" rows="6" class="form-control markitupEditor-textile_full" id="markitup_textile_1" name="REX_INPUT_VALUE[1]">REX_VALUE[1]</textarea>
        </div>
    </div>

</fieldset>
&

Code: Alles auswählen

<?php
if (!isset($counter)) {
	$counter = 0;
}
$counter++;
// Write data in an array for Frontend, but do not show them
if (! rex::isBackend()) {
	$items = array();
	$items = ['title' => '<img style="width:50px;border-radius:10px;margin-right:15px;" src="/media/REX_MEDIA[1]" /> <h5 style="display:inline-block;">REX_VALUE[2]</h5>', 'text' => 'REX_VALUE[id=1 output=html]'];
	rex::getProperty('tabs')->append($items);
// Im Backend wird der Inhalt als Info für den Redakteur angezeigt
} else {
	if ('REX_VALUE[id=2 isset=1]') {
	    echo '<h2>REX_VALUE[2]</h2>';
	}
	if ('REX_VALUE[id=1 isset=1]') {
	    echo '<p>REX_VALUE[1]</p>';
	}
}
?>
08 . Akkordeon Tabs (Ausgabe)

Code: Alles auswählen

<!-- *******************************************************
TABS AUSGABE
******************************************************** -->

<fieldset class="form-horizontal">
    <div class="form-group">
        <label class="col-sm-2 control-label" for="headline">Überschrift</label>
        <div class="col-sm-10">
            <input class="form-control" id="headline" type="text" name="REX_INPUT_VALUE[2]" value="REX_VALUE[2]" />
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-2 control-label" for="headline-level">Tab-Stil</label>
        <div class="col-sm-10">
			<?php
				$options = array(
				'ba'=>'Button-Akkordeons',
				'ta'=>'Text-Akkordeons',
				'bt'=>'Button-Tabs',
				'vt' => 'Vertikale Tabs',
				'tt' => 'Text-Tabs'
			);
			?>
			<select name="REX_INPUT_VALUE[1]" id="headline-level" class="form-control">
			<?php foreach ($options as $k=>$v) : ?>
			<option value="<?php echo $k; ?>"<?php if ($k == "REX_VALUE[1]") echo ' selected="selected"' ?>><?php echo $v; ?></option>
			<?php endforeach ?>
			</select>
        </div>
    </div>

	<!--
	<div class="form-group">
        <label class="col-sm-2 control-label" for="headline-level">falls Akkordeon</label>
        <div class="col-sm-10">
			<?php
				$options = array(
				'one-open'=>'Akkordeon schließt anderes',
				'multi-open'=>'mehrere Akkordions offen'
			);
			?>
			<select name="REX_INPUT_VALUE[3]" id="headline-level" class="form-control">
			<?php foreach ($options as $k=>$v) : ?>
			<option value="<?php echo $k; ?>"<?php if ($k == "REX_VALUE[3]") echo ' selected="selected"' ?>><?php echo $v; ?></option>
			<?php endforeach ?>
			</select>
        </div>
    </div>
	-->
</fieldset>
&

Code: Alles auswählen

<?php

$items = '';
$item = '';
// In frontend read array
if (!rex::isBackend()) {
	$items = rex::getProperty('tabs')->getArrayCopy();

	$textile = '';
	$tabs_title = '';
	$tabs_text = '';
	$tabs_out = '';
	$counter = 1;

	$title_style = 'title';
	$content_style = 'content';
	if ("REX_VALUE[1]" == 'tt' || "REX_VALUE[1]" == 'vt' || "REX_VALUE[1]" == 'bt') {
		$title_style = 'tab-title';
		$content_style = 'tab-content';
	}
	$one_open = ("REX_VALUE[3]" == 'one-open') ? " one-open" : "";

	foreach ($items as $item) {

		if (! isset($item['title'])) { $item['title'] = ''; };
		if (! isset($item['text'])) { $item['text'] = ''; };

		$active_title = '';
		$active_text = '';

		$tabs_title = $item['title'];
		$tabs_text = $item['text'];

		if ($tabs_title != '' && $tabs_text != '') {
			if ($counter == 1) $active_title = ' class="active"';

			$textile = markitup::parseOutput('textile', $tabs_text);
			$textile = str_replace(array('<b>', '</b>', '-&gt;'), array('<span class="label label-primary">', '</span>', '->'), $textile);

			$tabs_out .= '
			<li'.$active_title.'>
				<div class="'.$title_style.'">
					<span>'.$tabs_title.'</span>
				</div>
				<div class="'.$content_style.' text">'.$textile.'</div>
			</li>';
		}

		$counter++;

	}
	?>

	<section class="<?php if ($this->getTemplateId() == 1) echo 'container clearfix '; ?>tabs">
			<div class="row">
				<div class="col-md-12">

					<?php
					if ("REX_VALUE[2]" != '') {
						echo '
						<h3>REX_VALUE[2]</h3>';
					}

					if ("REX_VALUE[1]" == 'tt') { // Text-Tabs
						echo '
						<div class="tabbed-content text-tabs">';

					} elseif ("REX_VALUE[1]" == 'vt') { // Vertikale Tabs
						echo '
						<div class="tabbed-content button-tabs vertical">';

					} elseif ("REX_VALUE[1]" == 'bt') { // Button-Tabs
						echo '
						<div class="tabbed-content button-tabs">';
					}

					if ("REX_VALUE[1]" == 'ta') { // Text-Accordions

						echo '
						<ul class="accordion accordion-2'.$one_open.'">'.
							$tabs_out.'
						</ul>';

					} elseif ("REX_VALUE[1]" == 'ba') { // Button-Accordions

						echo '
						<ul class="accordion accordion-1'.$one_open.'">'.
							$tabs_out.'
						</ul>';

					} else {

						echo '
						<ul class="tabs">'.
							$tabs_out.'
						</ul>';

					}

					if ("REX_VALUE[1]" == 'tt' || "REX_VALUE[1]" == 'vt' || "REX_VALUE[1]" == 'bt') {
						echo '
						</div>';
					}
					?>

				</div>
			</div>
	</section>

	<?php
} else {
	echo '
	<p>Output only in frontend</p>';
}

?>
wie gesagt, habs mit removeProperty('tabs'); setProperty('tabs',' ');... versucht - ben

Re: rex::Property löschen

Verfasst: 22. Mär 2017, 14:42
von runstop64
Das ist aus der rex_demo, oder?

Die Property ist nicht automatisch vorhanden, sondern wird über das Template 00.Header gesetzt.
Wenn Du sie zurücksetzen möchtest, musst Du daher die Property neu setzen (statt löschen). Im Template ist das augenscheinlich die Zeile 18:

Code: Alles auswählen

rex::setProperty('tabs', new ArrayIterator());
Wenn Du diese Zeile an den Anfang Deines Moduls setzt, könnte es klappen (ungetestet). Kann natürlich Auswirkungen auf den Rest der Seite haben.
Falls es Probleme gibt, könntest Du für deine Module eine eigene Property setzen und abfragen, also alle

Code: Alles auswählen

...Porperty('tabs',...)
mit

Code: Alles auswählen

...Property('meine_property',...)
ersetzen.

Re: rex::Property löschen

Verfasst: 22. Mär 2017, 14:59
von beyben
ja geil, und zack sitzt es - hab dank! so kann man die module dann auch einfach mehrmals setzen...
ben