I would like to use getter instead general variable with dynamic snippets
Notice: This thread is very old.
- Prado
- Member | 21
required has triggered error: “Undefined property: Article::$getId”
{snippet article-$article->getId()}
...
{/snippet}
workaround:
{var $articleId=$article->getId()}
{snippet article-$articleId}
...
{/snippet}
(I'm not using Nette/Object as parent class of Article and I don't want to be.)
- Majkl578
- Moderator | 1364
That wouldn't work even in PHP itself:
class Foo {
public function getBar() { return "hello"; }
}
$foo = new Foo();
echo "$foo->getBar()"; // Notice: Undefined property: Foo::$getBar
You might try something like this:
{snippet "article-{$article->getId()}"}
Not sure if that would work though.