How to pass a variable from Pressenter to latte template

Notice: This thread is very old.
asinkan
Member | 38
+
0
-

Hello,

I have a function in the DashboardPresenter. This function calls template MyTempla

public function myFormSucceeded($button)
	{
		$this->template->name = $button->getForm()->getValues();
		$this->redirect('myTempla');

	}

how can I send my data to myTempla template?

{block content}

<h1>{$name}</h1>

I can set it in the render, but how to pass it to the render and how to call render?

	public function renderMyTempla()
	{
		$this->template->name=....;
	}

Thx

Last edited by asinkan (2018-01-26 10:57)

Šaman
Member | 2594
+
+2
-

Tady se to řešilo.


Ou, sorry, this is english forum.

<?php
$this->redirect("Presenter:view", $value);

// …

public function renderView($value)
{
  $this->template->value = $value;
}
?>

Last edited by Šaman (2018-01-26 10:34)

David Matějka
Moderator | 6439
+
+1
-

when you redirect, variables passed to a template are lost. so either don't redirect or pass variables via url (or session)

asinkan
Member | 38
+
0
-

OK, the solution…

Presenter:

public function renderMyTempla($name)
	{
		$this->template->name=$name;
	}

public function myFormSucceeded($button)
	{
		$name = $button->getForm()->getValues();
		$this->redirect('myTempla',$name);
	}

Latte template:

{block content}

<h1>{$name}</h1>