Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic snippets: only they are put to payload #501

Closed
wants to merge 1 commit into from

Conversation

vojtech-dobes
Copy link
Contributor

{snippet container}
    {foreach [1, 2, 3] as $id}
        {snippet dynamic-$id} ... {/snippet}
    {/foreach}
{/snippet}

Now, you have to invalidate only static snippet container. With my alteration, you have to invalidate both static snippet and dynamic snippet - and only dynamic snippet is put to payload. I believe it's the ussual desired behavior. Also, when you invalidate only static snippet, it adds all dynamic snippets as one item to payload (simply whole content of static snippet).

Example:

$this->invalidateControl('container');
$this->invalidateControl('dynamic-2');

results to payload:

{
    snippets: {
        'snippet--dynamic-2': ...
    }
}

@hrach
Copy link
Contributor

hrach commented Jan 31, 2012

No, ne, ze bych byl v kodu snippetu zbehly, takze substr(x, 9) moc nechapu, nicmene chybi mi testy a jestek k tvemu popisu, prijde mi, ze posledni veta je presne to, co nechci. Pokud invaliduji pouze container, tak chci vsechny dynamicky snippety, pokud invaliduji pouze container a dynamic-1, tak chci pouze dynamic-1.

@vojtech-dobes
Copy link
Contributor Author

Tou poslední větou jsem to zamotal... funguje to přesně jak říkáš ty. Jde jen o to, že se to nepošle rozdělené do dynamických snippetů, ale pošle se celý ten kontejner jako jedna položka v payloadu.

@vojtech-dobes
Copy link
Contributor Author

Co se týče testů - rád bych, ale na metodu renderSnippets pokud vím neexistují žádné testy ani teď, a moc nevím, jak na ně.

@natrim
Copy link
Contributor

natrim commented May 4, 2012

mohl bych vědět jakto vypada s touto úpravou?
docela by se hodilo mít možnost invalidovat jen jeden dynamický snippet a ostatní ne

@vojtech-dobes
Copy link
Contributor Author

The way how to achieve that (and with performance benefit this pull request only bypasses, not solves) is to narrow the iterated array in template for desired AJAX request. Something like this in handle method:

if ($this->isAjax()) {
    $this->template->myArray = array(1);
}

Sorry for English, I am switched and don't want to translate it to Czech now ;)

@dg
Copy link
Member

dg commented Dec 11, 2013

To narrow the iterated array in template is correct solution.

@dg dg closed this Dec 11, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants