News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Issue with load_template function, modified subs.php

Started by Glyph, November 21, 2015, 11:59:20 PM

Previous topic - Next topic

Glyph

my code

index.php
after: 'xmlhttp' => array('Xml.php', 'XMLhttpMain'),
add: 'pvp' => array('pvp.php', 'PvPMain'),

pvp.php
<?php
if (!defined('SMF'))
die('Hacking attempt...');

function 
PvPMain()
{
    global 
$scripturl$context$txt;
    
loadTemplate('pvp');
echo(
"this is a test");
}


Subs.php
before: 'mlist' => array(
add:                         'menu_pvp' => array(
'title' => 'PvP Rankings',
'href' => $scripturl . '?action=pvp',
'show' => true,
'sub_buttons' => array(
'sub_menu_action' => array(
'title' => 'Registration',
'href' => $scripturl . '?action=pvp;sa=register',
'show' => true,
'is_last'=> true,
),
),
),


So i've added myself a custom link in SMF, the issue is that the custom page i'm making needs a template.
I have no idea where this is coming from, i read help.php, calender.php, etc.. and i noticed something missing from my script..

a function called load_template, which i just added.

where is this called from? from my research its load.php?

I found another post with an issue, but they have a file with their stylesheet info it would seem in a file called Logbook.template.php
http://www.simplemachines.org/community/index.php?topic=537462.msg3819453#msg3819453


I'm assuming creating pvp.template.php will solve my issue, but what exactly is the file for and how is it interpreted? is there any documentation?
Personal TODO:

C. Davis

#1
The template file is where all the html and 'echoing' is. Your pvp.php gets all the database data and gives it to pvp.template.php.

Also, you will want to create a language file. It's done basicly the same way as the template.

And about documentation, it's easier to just see how all the vanilla smf stuff does it and figure it out like that. And the Route->Function->View structure is common to a lot of PHP frameworks.

Glyph

Quote from: C. Davis on November 22, 2015, 12:25:13 AM
The template file is where all the html and 'echoing' is. Your pvp.php gets all the database data and gives it to pvp.template.php.

Also, you will want to create a language file. It's done basicly the same way as the template.

And about documentation, it's easier to just see how all the vanilla smf stuff does it and figure it out like that. And the Route->Function->View structure is common to a lot of PHP frameworks.

I see! I have set up a new pvp.php and pvp.template.php so that it does exactly that now.
Thanks for the info. I have set up the structure accordingly and all is working well. =D

I have another question, is it typical to use the "default" directory in "themes" for custom modifications like this?
Personal TODO:

Kindred

Yes.  All template files must exist in the default theme directory. They may also exist I. Custom directories for custom designs... But the default theme directory is the fallback location and must have all template files.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Advertisement: