phproberto / joomla-twig

Twig 2.0 & Twig extensions integration for Joomla! https://phproberto.github.io/joomla-twig/
Other
25 stars 7 forks source link

Including an article or rendering from a string #68

Open venomdev opened 3 years ago

venomdev commented 3 years ago

Is it possible to include an article into a template and also have the article scanned for any twig fields?

Or is it possible to render from a string?

twentyfortysix commented 3 years ago

I'm not sure if it is not too late, but if you still have this issue if will be more clear I think we can find solution ;) if you want an article pop up in twig you should send the date to twig first

like

defined('_JEXEC') or die;
$data = array(
'type' => 'category',
    'params' => $this->params,
    'items' => $this->leading,
    'pagination_html' => $this->pagination->getPagesLinks(),
    'current_page' => $this->params->get('catPagination'),
    'total_pages' => $this->pagination->getPagesCounter()
);
JLoader::import('twig.library');
echo Twig::render('@template/com_k2/category.html.twig', $data);

in twig you do something like {{ current_page }} ...

God bless Twig!