List template?
oliverschloebe opened this issue · comments
Hi,
first off, thanks for your highly useful SDK! Helped me get a bot up and running real quick. :)
Are there any plans to include the new list template anytime soon?
Thank you!
Oliver
Hello @AlphawolfWMP ! Good catch, I will include this feature soon. I'm a bit busy but If you want, feel free to add the implementation.
@AlphawolfWMP If you want to try #36 before I merge it.
@tgallice Nice, thank you! I'll be creating a test bot to test your changes and new list template. :)
Hi @tgallice, I'm probably doing it wrong, but I can't get a list template to be rendered. Actually I don't even get an error, just my bot not printing the list. 😃
Here's the code I use:
$elements = array();
foreach() {
$element = new \Tgallice\FBMessenger\Model\Attachment\Template\ElementList\Element(
$title,
$subtitle,
$imageUrl,
new \Tgallice\FBMessenger\Model\Button\Share(),
new DefaultAction('https://www.domain.com/')
);
$elements[] = $element;
}
$template = new \Tgallice\FBMessenger\Model\Attachment\Template\ElementList($elements);
$this->messenger->sendMessage($event->getSenderId(), $template);
As soon as I change
$template = new \Tgallice\FBMessenger\Model\Attachment\Template\ElementList($elements);
back to
$template = new \Tgallice\FBMessenger\Model\Attachment\Template\Generic($elements);
it renders the carousel template without errors, but not the list template.
Any idea? 😃
Hi @tgallice, my fault obviously. I hadn't noticed the list template does need between 2 and 4 elements, otherwise it will fail/throw an exception. Providing an elements array between 2 and 4 elements does work indeed as intended. Thank you!
Sorry for the confusion. 😧
Hi @AlphawolfWMP sorry for just answering you now... Yes as defined in the documentation a list template must contain between 2 or 4 elements :) Thank you to have taking time to try this feature !