Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

How to create a simple PHP file ?

edited April 2016 in Vanilla 2.0 - 2.8

¿How Can I create a simple php file on my forum? I tried to create it but when I try to access from web I got 404 error, I checked many times as I can and found that the location is 100% correct but accessing from web It throws me an error

That PHP file needs to have just and href tag

Somebody can help me??


  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited April 2016

    You don't access a php file as you do an html file. Maybe you need to create an html file ?

    A php file with access is called a view, however it is more complex than html because you are dealing with php code.

    Your question should be : "How do I create a view I can access with a url ?"

    In that case you need to look at plugins like Extra Page , or PrivacyNotice , Or VChat , Or any other plugin which renders a view other than your main discussions template.

    Post the php file you created. We can't guess what you did…

  • Options
    jackmaessenjackmaessen ✭✭✭
    edited April 2016

    You can create a fresh new page on your forum by a simple plugin;
    Create a folder named e.g. spf (simple php file)
    In that folder create a file named default.php in which you put this code:

    <?php if(!defined('APPLICATION')) die();
    $PluginInfo['spf'] = array(
        'Version' => '1.0',
        'Name' => 'SPF',
        'Description' => 'SPF is a new page in Vanilla in which you can write php code',
        'License'=>"GNU GPL2",
            'Author' => "danytothetowers " 
    class spf_Plugin extends Gdn_Plugin {
        public function Base_Render_Before($Sender) {
        /* here you can add .js and .css files */   
              //$Sender->AddJsFile($this->GetResource('js/spf.js', FALSE, FALSE));
              //$Sender->AddCSSFile($this->GetResource('design/spf.css', FALSE, FALSE));
              $Session = Gdn::Session();
        public function PluginController_spf_Create($Sender) {
            $Session = Gdn::Session();
            if ($Sender->Menu) {
                $Sender->MasterView = 'default';
                $Sender->Render('spf', '', 'plugins/spf');
        public function OnDisable() {
                  $matchroute = 'spf';
                      Gdn::Router()-> DeleteRoute($matchroute); 
        public function Setup() {
                 $matchroute = 'spf';
                 $target = 'plugin/spf';

    Now create a new folder named: views ( in the spf directory)
    In the views folder you create a file named spf.php in which this code:

    <?php if(!defined('APPLICATION')) die();
    echo 'Start your page here; this line is created by an echo';
    <h2>This line is pure html </h2>
    another line in html

    Access your page by :

Sign In or Register to comment.