Render xml and write values into it

Im working on a site that uses krpano to embed enormous images into it. This plugin is configured via an xml file, but ideally i need to configure that xml file via the panel. Is the best approach a route or a virtual page? How would get the values i need from the content that sits along side it?

The structure looks like this…

2_mypage
  flatpano_setup.xml
  macro.txt
  my_image.jpg
  my_image.jpg.txt
  pano.xml
  tiles

I need to set values in flatpano_setup.xml that are stored content file macro.txt which is controlled by the panel, so flatpano_setup.xml needs to be dynamic somehow.

Whats the best way to do it?

I’ve kind of solved it by storing the values in the session and picking them back up in a virtual page, but it feels a little hacky… is there maybe a better way?

  // Pano Config
  [
    'pattern' => '/macros/(:any)/flatpano_setup.xml',
    'action'  => function () {
      return Page::factory([
          'slug' => 'flatpano_setup',
          'template' => 'flatpano_setup',
          'model' => 'flatpano_setup',
          'content' => [
              'maxzoom' => kirby()->session()->get('macro.maxzoom', '0.5'),
          ]
      ]);
    }
  ]

Hm, if your route should return the xml file, why do you set it up as a virtual page? Guess I’m missing something here…

Because the xml file does not physically exist but theres a line in it:

<view fovtype="HFOV" fov="1.0" fovmax="1.0" maxpixelzoom="1.0" limitview="lookat" />

I need to set the zoom from the other page, so ive passed it over through the session.

When i visit /macros/somepage it sets the session from that page

Exactly, if the xml file does not physically exist but is returned from the route, your route can render it with the data from the page. I don’t get the session part.

Well theres about 20 pages, each with one of these zoomy things on. Kirby sees them as two seperate things, so i couldnt see a way to share value besides the session. And the xml is about 50 lines long, so i didn’t want to throw all that in a route.