CodeIgniter Forums
Why View Parser Filter not working on Loop Substitutions ? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Why View Parser Filter not working on Loop Substitutions ? (/showthread.php?tid=77020)



Why View Parser Filter not working on Loop Substitutions ? - wahmal - 07-12-2020

Hi, i try to make template with view parser ci4

in my case, i have data example like this :
Code:
$data=['blog_entries' => [
                   ['post' => '2020-02-02']
];
 
and i want to change date format to 'd-m-Y' using filter view parser

 
Code:
{blog_entries}
        <div>{post|date(d-m-Y)}</div>
{/blog_entries}

But it doesnt work


RE: Why View Parser Filter not working on Loop Substitutions ? - InsiteFX - 07-12-2020

Your missing the quotes on the date.

Code:
{blog_entries}
        <div>{post|date('d-m-Y')}</div>
{/blog_entries}

Try that if it doe's not work then something else is wrong, hard to tell without see more of the code.


RE: Why View Parser Filter not working on Loop Substitutions ? - emilt - 09-11-2020

(07-12-2020, 08:20 AM)InsiteFX Wrote: Your missing the quotes on the date.

Code:
{blog_entries}
        <div>{post|date('d-m-Y')}</div>
{/blog_entries}

Try that if it doe's not work then something else is wrong, hard to tell without see more of the code.
I am just starting to try CI4 and I ran into the same problem. And - no, the problem is not with the quotes, the same filter works fine without quotes if out of the loop. And the loop works fine if the date filter is not applied on the date.


RE: Why View Parser Filter not working on Loop Substitutions ? - Ilham Fadil - 08-11-2021

got same problem


RE: Why View Parser Filter not working on Loop Substitutions ? - jctorres - 02-24-2022

I'm having the same issue.
I have a value inside an array so when I'm trying to use filter, Parser shows the "brute code". This happens when I call filters with parameters, like number_format.
Code:
{array}
  {subarray}
      {value|number_format(3)}
  {/subarray}
{/array}

This doesn't work. Will show same code on the view.


On the other hand if I use "abs", works with no problem.
Code:
{array}
  {subarray}
      {value|abs}
  {/subarray}
{/array}
Shows as expected and getting transformed data.


Any ideas why is this happening?????


RE: Why View Parser Filter not working on Loop Substitutions ? - rdconsolo - 06-07-2022

Follow the instructions posted here: https://github.com/codeigniter4/CodeIgniter4/issues/5825
Works for me on CI 4.2.0