XF 2.2 How To Add A New Admin CP Option?

It’s Fait

New member
Hello,
i have made a few xenforo plugins but now i want to add a new page in the admin CP so you can do back end stuff without needing to access the database to do these, So how am i able to create a new page with in the admin cp?

i've googled and looked everywhere but not much results thank you!
 

Hoffi

Well-known member
The Controller goes into the Admin/Controller Folder inside your AddOn Directory.
Then you need to add Admin Routes in the AdminCP in the Developer Section.

/admin.php?routes/#admin

Just grap any existing route which fits most to your needs, and create your own likewise.
It works the same like for public routes.
 

It’s Fait

New member
i'm honestly new to controllers i've made a few profile add ons about it

i've tried this but still no luck<?php
namespace XF\Admin\Controller;

class Fait extends AbstractController
{


public function actionExample()
{
$hello = 'Hello';
$world = 'world!';

$viewParams = [
'hello' => $hello,
'world' => $world
];
return $this->view('Admin:fait', 'member_view', $viewParams);
}




}
?>
 

Hoffi

Well-known member
Then start with this:


member_view is an existing template, you need to add the needed viewParams to that. And, of course, member_view is a public template, not an admin template.

Mybe just build the demo portal AddOn with this guide, this is also a good startig point:


After that consider readinf the "new to developers" Threads in the have you seen Forum.
 

It’s Fait

New member
thank you loads for your help i highly appreciate it :)
i managed to make a test page through the templating system by using the controller so i think i should be able to figure the rest out now
 

It’s Fait

New member
i've also learnt that this code can directly load a template from anything so as i'm going a long things is getting easier in working with this softeware as i'm trying to add on to things to make a unique site

$template = \XF::app()->templater()->renderTemplate('public:template',$testing);
 
Top