CodeIgniter Forums
Get value from array without loop on parased template - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forum-28.html)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forum-30.html)
+--- Thread: Get value from array without loop on parased template (/thread-74810.html)



Get value from array without loop on parased template - andru3dward - 11-10-2019

Hello, 
i need to get value from array in a parased template, so in my case:
  • I made a template system where all templates end in .tpl
  • second, i need to get an value from a array like that 
Code:
{member.name}
 or 
Code:
{$member.name}

 without usinge metod like 


Code:
{member}
    {name}
{/member}
Like Smarty template Engine do

This is my code:

Code:
$data = [
      'member'      => $member->memberInfo(),  // Array from DB if the member is logged otherwise it is false
      'content'   => $this->body
];

print $parser->setData( $data, 'raw' )->render( $layout );


I was not able to find it in the documentation or in the code and I need this in templates

I hope you get it cuz in this moment i can't exprime myself   Dodgy