XF 2.3 I have custom php page. I want to make a page inside of Xen - getting an error

L3gacy

Active member
I created a node with the PHP callback \AmmoForm\index with getData method. I wrapped the entire index.php file like so:

Code:
<?php
namespace AmmoForm;
class Index{
index.php contents
}
?>

I then received an error stating "syntax error unexpected T_DECLARE expecting T_FUNCTION". Upon saving the node I received the following error:

ScreenShot_2025-05-03_2146_00016.webp

Any ideas what I'm doing wrong.
 
If you callback is AmmoForm\Index::getData then you should have a file src/addons/AmmoForm/Index.php that looks something like this:

PHP:
<?php

namespace AmmoForm;

use XF\Pub\Controller\PageContoller;
use XF\Mvc\Reply\AbstractReply;

class Index
{
    public static function getData(
        PageController $controller, 
        AbstractReply &$reply
    ): void
   {
        // manipulate $reply as necessary
    }
}
 
Although page callbacks let you manipulate the XF reply object however you like, they don't necessarily allow you to map a response from another file/framework cleanly if that's what you're trying to do. You could potentially use output buffering to capture output from the other file as a string and pass it to the template, but it's a bit hacky.
 
yeah I think I found out that the hard way. So in a nut shell you're saying I really cant do what I'm trying to do. and I would more or less need to make an addon for this?
 
Maybe, I can't say for certain without knowing more about what you're trying to do and what's in index.php.

Assuming index.php is a simple self-contained script that only does one action and doesn't rely on any input, you could potentially do something like this in the callback method:

PHP:
if (!($reply instanceof \XF\Mvc\Reply\View))
{
    return;
}

ob_start();
require '/path/to/index.php';
$output = ob_get_clean();

$reply->setParam('output', $output);

...which would make your index.php output available in the $output variable of the XenForo template.
 
LOL, $5,000 for copyright removal? No thanks. I’m not trying to be rude or anything, but I could just pay someone to make me a custom addon for WAY less and call it a day. I paid to remove the copyrights, not to have an addon include theirs with such an exorbitant price, especially when it’s just one section of the software that I already paid to have debranded.

This just proves the point I made to XenForo. Every single addon feels like they have a right to your footer, making it look like garbage unless you pay the price-gouging fee to remove it. Case in point. I feel Xenforo needs better way to give addons credit other than all the spam in the footer.


(Off Topic I Know)
 
Last edited:
branding free is just an additional costs, you can choose not to pay it and have the copyrights, but if its that important to you, you will pay the branding free options, xenforo's branding free doesn't cost very much if your serious about removing it, also if a plugin adds too many links to footer I either upgrade or don't use the plugin, simple. removing the copyright yourself is just breaking the tos and is pirating at the end of the day. my opinion if your footer has too many links like that you have way too many addons anyway.
 
@InfernoDev That guy DM'ed me swearing before posting an almost identical message here (substituting his swearing with "I'm not trying to be rude" here), thinking that ranting in public and blaming everyone else was somehow going to get him his way.

Good riddance.
I don't know I was tagged in here from his other thread LOL. totally random place to rant about that. seems like the kind of guy that doesn't tip.
 
Back
Top Bottom