XenForo 2.0 Custom Page with PHP

Anonimo88

Member
Registered
Joined
Apr 23, 2021
Messages
9
Points
3

Reputation:

Hello,
I'm trying to play a PHP game I made on my old forum ..

To start I created a folder with a file inside it in src/FI/ named index.php, inside I inserted this code:
PHP:
<?php
namespace FI;

class index
{
    public static function test(\XF\Pub\Controller\AbstractController $controller, \XF\Mvc\Reply\AbstractReply &$reply)
    {
        $params = [
            'example' => "work!"
        ];
        $reply->setParams($params);
    }
}

Then I created a node of type Page and I inserted the PHP callback of the class as follows:
FI\index :: test

This works if inside the class I insert a simple:
PHP:
echo "test";
Although this is displayed above the breadcrumb and not below the title ..!

Unfortunately, however, if I insert a {xen: raw $example} in the HTML code it is displayed as it is .. Where am I wrong?
 

Soft4Win

Developer
Staff member
Moderator
Collaborate
Registered
Joined
Apr 27, 2019
Messages
216
Points
73

Reputation:

Are you using the {xen:raw } in version 2 of xenforo?

{xen:raw} was used in version 1 of xenforo, however now xenforo uses filters for many work.

So for it to work in xenforo 2 do this :-

{$example|raw}
 
Top