Virtual page - merge from page data

Hi there.
I have a virtual page. But i just want to set one field. The other content data should be set by the desired page. Is there a method to get the default content of the page to merge it with the incoming value?

  return [   
   [
    'pattern' => 'shop/(:any)',
    'action'  => function ($name) {
     return Page::factory([
      'slug' => 'shop',
      'template' => 'shop',
      'model' => 'shop',
      'content' => array_merge([
       "my_data" => $name
      ])
     ]);
    }
   ]
  ];
 }

If i run this route. I get this error:

preg_replace_callback(): Passing null to parameter #3 ($subject) of type array|string is deprecated in
kirby/src/Text/KirbyTags.php line 33

I don’t quite understand what you are trying to do.

If you want to return the shop page, why don’t you render it with additional data:

Okay. That was simple. :flushed:
Sometimes i went so far to see how simple Kirby ist. :man_facepalming:

Hello,

I have the same problem. I have a virtual page for render in an other template my article.
It’s working perfectly in local, but online I have the error :

Whoops \ Exception \ ErrorException (E_DEPRECATED)

preg_replace_callback(): Passing null to parameter #3 ($subject) of type array|string is deprecated

My code in config.php :

  'routes' => [
    [
      'pattern' => '(:any)/print/(:all)',
      'action' => function ($lang, $page_id) {
        $p = page('print');
        return $p->render([
          'article' => page($page_id)
        ]);
      }
    ],
  ]

I fixed it by changing the version of PHP on my server from 8.1 to 7.4