I'm trying to create xenforo page and display weather data from external xml file provided by national meteorological institute.
See how I set up $viewParams to be used in the view template.
You are done with PHP that loads the remote XML file and parses it. Now it is time to create the XenForo page and make the connection between the page and the PHP callback.
Go to XenForo Admin->Forums->Nodes and click Add Node. Set the parameters in the first screenshot below as you need:
The second screenshot below is more important. The template that will show the view parameters coming from the PHP callback, and the path for the callback function. You can design the template as you desire by following the sample of how I did.
Weather\Weather -> the first one is the folder name in the addons directory, the second one is the PHP class name.
index -> function name in the class.
Save the page, and go to the forum to click on the page in the nodes list. It shows the following in my implementation as I explained step by step above.
It can be also created as a custom widget, but it is different than setting up it as a page. I believe this will provide a starting point.
Please note this is not the preferred method, making the remote call every time the page is displayed. Instead of that, you should cache this info somewhere (preferably in the database) and serve from the database instead of reading the remote source. Then you can refresh the data in the database periodically. Although the XenForo page cache will also do a similar caching, it will be only for a less time period. However, you'll likely need this info to be updated every 24 hours. So, I strongly recommend building your cache mechanism for this purpose.