Snippets in component are redrawing only in render() view

medhi
Generous Backer | 255
+
0
-

I have a component with more views:

	public function render()
	{
		$this->template->setFile(__DIR__ . '/templates/admin.latte');
		$this->template->render();
	}

	public function renderDialog()
	{
		$this->template->setFile(__DIR__ . '/templates/dialog.latte');
		$this->template->render();
	}

Also I have snippets in both templates, admin.latte and dialog.latte. When I try to redraw a snippet, which is placed in admin.latte, it works.

But if it is placed in dialog.latte, it is not redrawn, the snippet is not sent in the JSON.

How to redraw a snippet in dialog.latte?

David Matějka
Moderator | 6445
+
+4
-

Hi, this is known limitation. You can wrap {control foo:dialog} into snippetArea and re-render this snippetArea as well (using $this->parent->redrawControl(...)).

But in general I do not recommend using multiple component views.

I've talked about this and some other snippet issues few years ago on Posobota (czech only)

dsar
Backer | 53
+
0
-

David Matějka wrote:

But in general I do not recommend using multiple component views.

I've talked about this and some other snippet issues few years ago on Posobota (czech only)

Why you do not recommend using multiple component views?

(Unfortunately that talk is czech only…)

CZechBoY
Member | 3608
+
+1
-

It's easier to maintain.

dsar
Backer | 53
+
0
-

CZechBoY wrote:

It's easier to maintain.

Yes, having 1:1 between components and views is conceptually easier, but sometimes I find useful to have more views per component.

I thought there were known problems with them (not related with snippets)