News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

new profile section don't load template - please help finding error

Started by mano82, June 18, 2015, 10:46:32 AM

Previous topic - Next topic

mano82

hallo,

I am trying to make a little mod by implementing a new section to the user profile area. I looked at other similar mods (member awards, ultimate profle, ...) and tried to copy the syntax, but I have the error "Unable to load the '[page name goes here]' template."

Here's the changes I made (hard coded for test...will make install.xml file when the mod will work).

1. main idea to have a new menu inside the user profile page. the new section will be called Logbook and will be composed by two functions viewLogbook and viewTraining.

Here's how I changed the Profile.php structure:

<?
......
),
'logbook' => array(
'title' => 'Logbook',
'areas' => array(
'viewlogbook' => array(
'label' => 'Logbook',
'file' => 'Logbook.php',
'function' => 'viewlogbook',
'permission' => array(
'own' => 'profile_view_own',
'any' => 'profile_view_any',
),
),
'viewtraining' => array(
'label' => 'Accademia',
'file' => 'Logbook.php',
'function' => 'viewTraining',
'permission' => array(
'own' => 'profile_view_own',
'any' => 'profile_view_any',
),
),
),
),
'edit_profile' => array(   ........
?>


this goes between the two menus Profile info and Modify Profile. It works till now.

2.
I created the Sources\Logbook.php file as:


<?php
// First of all, we make sure we are accessing the source file via SMF so that people can not directly access the file. 
if (!defined('SMF'))
die('Hack Attempt...');

function viewLogbook($memId)
{

// Second, give ourselves access to all the global variables we will need for this action
global $context$scripturl$txt$smcFunc;

// Third, Load the specialty template for this action.
loadLanguage('Logbook');
loadTemplate('Logbook');


//Fourth, Come up with a page title for the main page
$context['page_title'] = 'TEST LOGBOOK';#$txt['titolo'];


//Fifth, define the navigational link tree to be shown at the top of the page.


//Sixth, begin doing all the stuff that we want this action to display
//    Store the results of this stuff in the $context array.  
//    This action's template(s) will display the contents of $context.
$context['titolo'] = 'Manomods Logbook';
$context['manomod_Body'] = 'hey say hello!';

}

function viewTraining()
{
# something else will go here
}
?>


3. then I created the template file as Themes\default\Logbook.template.php


<?php

function template_main()
{

// Make sure we have all the global variables we need
global $context;

// Catbg header
echo '<div class="cat_bar">
    <h3 class="catbg">'
$context['titolo'], '</h3>
</div>'
;

// Windowbg2 Content
echo '<div class="windowbg2">
   <span class="topslice"><span></span></span>
      <div class="content">'
$context['manomod_Body'], '</div>
   <span class="botslice"><span></span></span>
</div><br />'
;

}

?>


The profile navbar is ok and shows the "Logbook" area with the two subbuttons "Logbook" and "Accademia". Links are:
http://localhost/smf2/index.php?action=profile;area=viewlogbook;u=1

However when I click I get the error message:
Unable to load the 'viewlogbook' template.

Any idea where I'm getting wrong or how to solve?

ps: the language file will be done later...I don't think it is a problem at this time.

many thanks in advance.

mano82

bump...

still no idea how to solve it...I figured out that with an other piece of code working as an action, if put in my script doesn't work aswell...so maybe the problem is something related to the "profile area" that I'm not understanding...

Suki

You need to load your language and template files in function viewTraining()  and all other functions you might add.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

mano82

thank you Suki for the reply. However it still doesn't work.
I've corrected by copying the contento of the viewLogbook function to the viewTraining, uncommenting the loadlanguage and editing the Logbook.english.php file in themes/default/languages...

still no joy I get the errors "Unable to load the 'viewLogbook' template.", and "Unable to load the 'viewTraining' template.

Shambles

Just thinking out loud (and trying to help), does capitalisation matter?

Code (find) Select
'function' => 'viewlogbook',

Code (relace) Select
'function' => 'viewLogbook',

margarett

Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

mano82

Quote from: Shambles on June 30, 2015, 08:01:40 AM
Just thinking out loud (and trying to help), does capitalisation matter?

Code (find) Select
'function' => 'viewlogbook',

Code (relace) Select
'function' => 'viewLogbook',

thanks for the hint but no joy. The function calls are exact to the names of the functions....  :-[

Morsyl

The profile code sets the template based on what you define in the 'function' attribute. So the template function in Logbook.template.php needs to be template_viewlogbook (with whatever case sensitive adjustments you need) instead of template_main.

Advertisement: