Zum Inhalt springen

Fluid - Bild mit TS konfigurieren (f:cObject) - was mache ich falsch?

Erstellt am 15. Oktober 2012 · 2 Antworten · letzte Antwort am 15. Oktober 2012

Tags: Fluid, Frage

bberger ·

Hallo liebe Community,

brauche wieder einmal ein bisschen Rat:

ich möchte ein Titelbild einer Melone im View anzeigen, das Ganze jedoch per TS konfigurierbar machen (sprich mit einem IMAGE-Objekt).

Momentan habe ich in meinem View:

<f:cObject typoscriptObjectPath="plugin.tx_melonenschlaraffenland.melonen.singleView.picture" data="{file: pictureTS.file}" />

In meinem MelonenController:

$pictureTS = array ('file' => $melone->getPicture());
		
$this->view->assign('pictureTS', $pictureTS);

und im TypoScript:

plugin.tx_melonenschlaraffenland {
  melonen {
    singleView {
      picture = IMAGE
      picture {
       
        file.import.current = 1
        file.import.field = file
        file {
          height = 300c
          width = 200c
        }
      }
    }
  }
}

Aber irgendwie wird da kein Bild daraus.. wenn ich im TS jetzt aber file=uploads/tx_melonenschlaraffenland/einexistierendesbild.jpg setze funktioniert es - ergo mache ich definitiv was bei der Zuweisung falsch - jedoch was genau? So ganz habe ich das leider noch nicht durchschaut.. o.O

LG
Bernhard

bberger ·

Hab das ganze jetzt so gelöst, dass ich das Model um eine Eigenschaft "getPicturePath" erweitert habe, welche mir den kompletten Pfad liefert. Nicht die schönste Lösung, aber funktioniert.

Achja, der Aufruf im View sieht nun so aus:

<f:cObject typoscriptObjectPath="plugin.tx_melonenschlaraffenland.melonen.singleView.picture" data="melone.picturePath" />

Controller:
garnix mehr

Model:

	/**
	 * Picture Path
	 *
	 * @var string
	 */
	protected $picturePath;

	/**
	 * Returns the full picture path
	 *
	 * @return string $picturePath
	 */
	public function getPicturePath() {
		return 'uploads/tx_melonenschlaraffenland/' . $this->picture;
	}

und im TS (das import.field rausgenommen):

plugin.tx_melonenschlaraffenland {
  melonen {
    singleView {
      picture = IMAGE
      picture {
        file.import =
        file.import.current = 1
        file {
          height = 300c
          width = 200c
        }
      }
    }
  }
}