News:

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

Main Menu

Adding New Modification Settings for SMF 2.0.2

Started by bigjoe11a, November 03, 2012, 09:41:55 PM

Previous topic - Next topic

bigjoe11a

I been reading threw this tutorial for the last 5 days and I don't under stand why this doesn't work. I'm trying to create one new tab and add 3 settings to it.

Here's the link for the tutorial.
http://www.simplemachines.org/community/index.php?topic=350344.0

I all ready added my 3 new settings to the database.
and here's my code.


function BJBlog_Settings(&$config_vars) {
     
  $subActions['bjblog'] = 'ModifyBJBlogModSettings';
}


function ModifyBJBlogModSettings($return_config = false) {   
   
    global $txt, $scripturl, $context, $settings, $sc, $modSettings, $txt;
   
    //Create a new tab
    $context[$context['admin_menu_name']]['tab_data'] = array(
'title' => $txt['admin_modifications'], //I don't know what this is for
'help' => 'modsettings',
'description' => $txt['modification_settings_desc'], // I don't know what this is for
'tabs' => array(
'bjblog' => array(
),
),
);
    //Add settings to the new tab
    $config_vars = array(
                   array('check', 'enabled_bjblog'),
                   array('int', 'bjblog_page_per_post'),
                   array('int', 'bjblog_page_per_comm'),
);
   
if ($return_config)
return $config_vars;
       
       
         //Save your new settings
$context['post_url'] = $scripturl . '?action=admin;area=modsettings;save;sa=bjblog';
$context['settings_title'] = $txt['BJBlog_Settings_Title'];

if (isset($_GET['save']))
{
checkSession();
saveDBSettings($config_vars);
redirectexit('action=admin;area=modsettings;sa=bjblog');
}

prepareDBSettingContext($config_vars);
   
}

SMF Forums http://www.df-barracks.com Where gamers go.

bigjoe11a

If I under stand this right. After looking at it for the last 5 days. The code below gets redirected and then it saves my new settings.


//Save your new settings
$context['post_url'] = $scripturl . '?action=admin;area=modsettings;save;sa=bjblog';
$context['settings_title'] = $txt['BJBlog_Settings_Title'];



if (isset($_GET['save']))
{
checkSession();
saveDBSettings($config_vars);
redirectexit('action=admin;area=modsettings;sa=bjblog');
}


Then code above saves the settings and it should show me the new settings page. How ever. There has to be some thing that I'm missing. This doesn't work.


SMF Forums http://www.df-barracks.com Where gamers go.

bigjoe11a

SMF Forums http://www.df-barracks.com Where gamers go.

Kays

So, what doesn't work? You need to be a bit more specific.

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

bigjoe11a

Well I fount out how to create a tab to the modifications section. It only took me 5 days to figure that out. The problem is that I can't get it to add the settings to my page. Let me show you what I have so far.

This code below should create my settings page and add a title to it a long with 3 settings to that page. and well I ran it like 100 times in different ways and well I still can't get it to do what it should do.

Code (php) Select

function BJBlog_Settings(&$config_vars) {
     
  $subActions['bjblog'] = 'Modify_BJBlog_Settings';
}

function Modify_BJBlog_Settings($return_config = false) {   
   
    global $txt, $scripturl, $context, $settings, $sc, $modSettings, $txt;
    //loadLanguage('BJBlog');
     
    $config_vars = array(
            array('check', 'enabled_bjblog'),
            array('int', 'bjblog_page_per_post'),
            array('int', 'bjblog_page_per_comm'),
);
   
if ($return_config)
return $config_vars;

$context['post_url'] = $scripturl . '?action=admin;area=modsettings;save;sa=bjblog';
$context['settings_title'] = $txt['BJBlog_Settings_Title'];

if (isset($_GET['save']))
{
checkSession();
saveDBSettings($config_vars);
redirectexit('?action=admin;area=modsettings;sa=bjblog');
        echo '<br />Saving Settings<br />';
}

prepareDBSettingContext($config_vars);
   
}


And last here are my hooks below

Code (php) Select

add_integration_function('integrate_pre_include', '$sourcedir/Subs-bjblog.php');
add_integration_function('integrate_actions', 'bjblog_add_hook');
add_integration_function('integrate_load_permissions', 'BJBlogAddPermissions');
add_integration_function('integrate_admin_areas', 'BJBlogAdmin');
add_integration_function('integrate_modify_modifications;', 'BJBlog_Settings', TRUE);



PLEASE, any ideas.
SMF Forums http://www.df-barracks.com Where gamers go.

Kays

In the following function, you need to pass $subActions as a parameter not $config_vars, like so:


function BJBlog_Settings(&$subActions) {
     
  $subActions['bjblog'] = 'Modify_BJBlog_Settings';
}

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

bigjoe11a

Well that all most worked. I change it and ran the hook again and well look at the image below and it did this for every one that was added in the modifications settings.

I thought that the $txt['BJBlog_Settings_Title'] was to be added in the modifications.english.php. That's where I added it at.
SMF Forums http://www.df-barracks.com Where gamers go.

bigjoe11a

Here's all of my code. I thought you mite need to see all of it.


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

function 
BJBlog_add_hook(&$actionArray) {
$actionArray['bjblog'] = array('bjblog.php''bjblogMain');
}


function 
BJBlogAddPermissions(&$permissionGroups, &$permissionList, &$leftPermissionGroups, &$hiddenPermissions, &$relabelPermissions) {

loadLanguage('BJBlog');

$permissionList['membergroup'] = array_merge(
array(
'bjblog_post' => array(false'bjblog''bjblog'),
'bjblog_comm' => array(false'bjblog''bjblog'),
'bjblog_blog' => array(false'bjblog''bjblog'),
'bjblog_view' => array(false'bjblog''bjblog'),
),
$permissionList['membergroup']
);
}

function 
BJBlog_Settings(&$subActions) {
      
  
$subActions['bjblog'] = 'Modify_BJBlog_Settings';
}

function 
Modify_BJBlog_Settings($return_config false) {    
    
    global 
$txt$scripturl$context$settings$sc$modSettings;
          
    
$config_vars = array(
            array(
'check''enabled_bjblog'),
            array(
'int''bjblog_page_per_post'),
            array(
'int''bjblog_page_per_comm'),
);
    
if ($return_config)
return $config_vars;

$context['post_url'] = $scripturl '?action=admin;area=modsettings;save;sa=bjblog';
$context['settings_title'] = $txt['BJBlog_Settings_Title'];

if (isset($_GET['save']))
{
checkSession();
saveDBSettings($config_vars);
redirectexit('?action=admin;area=modsettings;sa=bjblog');        
}

prepareDBSettingContext($config_vars);
    
}

function 
BJBlogAdmin(&$admin_areas)
{
global $txt;

$admin_areas['config']['areas']['modsettings']['subsections']['bjblog'] = array($txt['BJBlog']);
}

/*
function BJBlog_menu_buttons(&$menu_buttons) {
    
    global $context, $scripturl, $txt, $user_info;
    
    $menu_buttons = array(
'bjblog' => array(
'title' => $txt['BJBlog'],
'href' => $scripturl . '?action=bjblog',
'show' => !$user_info['is_guest'],
'sub_buttons' => array(
),      
            ),
);
}
*/

function BJBlog_who() {
    
    global 
$txt;
    
    
$BJBLOG '<a href="http://www.df-barracks.com">' $txt['bjblog_verison'].'</a>';
    
    return 
$BJBLOG;
    
    
}


?>


SMF Forums http://www.df-barracks.com Where gamers go.

Kays

Any errors in the error log?

Quote
I thought that the $txt['BJBlog_Settings_Title'] was to be added in the modifications.english.php. That's where I added it at.

The modifications language file is always a good place since that get's loaded with each page load.

Where are the $txt strings for the settings located? If they're in your bjblog language file. Then you should do a loadlanguage('bjblog'); at the beginning of the settings function. Then you can also add  $txt['BJBlog_Settings_Title'] there.

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

bigjoe11a

I took all the settings out of the modifications.english.php. and added them into my BJBlog.english.php php file and I still have the same problem.

and last, No I'm not getting any errors.

SMF Forums http://www.df-barracks.com Where gamers go.

bigjoe11a

Let me show you just what it's doing. I uninstalled all other mods I had installed. and look at the results after running the hook.

SMF Forums http://www.df-barracks.com Where gamers go.

bigjoe11a

And here's my code again


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

function 
BJBlog_add_hook(&$actionArray) {
$actionArray['bjblog'] = array('bjblog.php''bjblogMain');
}


function 
BJBlogAddPermissions(&$permissionGroups, &$permissionList, &$leftPermissionGroups, &$hiddenPermissions, &$relabelPermissions) {

loadLanguage('BJBlog');

$permissionList['membergroup'] = array_merge(
array(
'bjblog_post' => array(false'bjblog''bjblog'),
'bjblog_comm' => array(false'bjblog''bjblog'),
'bjblog_blog' => array(false'bjblog''bjblog'),
'bjblog_view' => array(false'bjblog''bjblog'),
),
$permissionList['membergroup']
);
}

function 
BJBlog_Settings(&$subActions) {
      
  
$subActions['bjblog'] = 'Modify_BJBlog_Settings';
}

function 
Modify_BJBlog_Settings($return_config false) {    
    
    global 
$txt$scripturl$context$settings$sc$modSettings;
     
     
loadLanguage('BJBlog');
          
    
$config_vars = array(
            array(
'check''enabled_bjblog'),
            array(
'int''bjblog_page_per_post'),
            array(
'int''bjblog_page_per_comm'),
);
    
if ($return_config)
return $config_vars;

$context['post_url'] = $scripturl '?action=admin;area=modsettings;save;sa=bjblog';
$context['settings_title'] = $txt['BJBlog_Settings_Title'];

if (isset($_GET['save']))
{
checkSession();
saveDBSettings($config_vars);
redirectexit('?action=admin;area=modsettings;sa=bjblog');        
}

prepareDBSettingContext($config_vars);
    
}

function 
BJBlogAdmin(&$admin_areas)
{
global $txt;

$admin_areas['config']['areas']['modsettings']['subsections']['bjblog'] = array($txt['BJBlog']);
}

/*
function BJBlog_menu_buttons(&$menu_buttons) {
    
    global $context, $scripturl, $txt, $user_info;
    
    $menu_buttons = array(
'bjblog' => array(
'title' => $txt['BJBlog'],
'href' => $scripturl . '?action=bjblog',
'show' => !$user_info['is_guest'],
'sub_buttons' => array(
),      
            ),
);
}
*/

function BJBlog_who() {
    
    global 
$txt;
    
    
$BJBLOG '<a href="http://www.df-barracks.com">' $txt['bjblog_verison'].'</a>';
    
    return 
$BJBLOG;
    
    
}


?>


SMF Forums http://www.df-barracks.com Where gamers go.

Kays

Off hand, I can't see why that's not showing.

Did they show before?

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

bigjoe11a

No, I never been able to get this far before now. and the problem is that it does this on ever one. So some thing is not set up right. Did you look at both images.

If you don't have any other ideas on what could be wrong, Now what do I do.
SMF Forums http://www.df-barracks.com Where gamers go.

Kays

It kinda looks like "integrate_modify_general_modifications" is still being called as well as "integrate_modify_modifications"

In the database Settings table, look for "integrate_general_mod_settings" and remove it. Or empty the variable field.

That's all I can think for now and it's getting late so good luck with this for now.

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

bigjoe11a

Ok, I'll let you know if it works and post here, good night for now and thanks
SMF Forums http://www.df-barracks.com Where gamers go.

bigjoe11a

Well I wanted to tell you I fount a lot of errors. I never thought that I changed the names and values so many times, That I didn't think that it would screw up the database too. Instead of updating the values it inserted new ones and it was so screwed up. No wonder it didn't work. I also fount some errors in my PHP code too. Look at this line


add_integration_function('integrate_modify_modifications;', 'BJBlog_Settings');


Do you see what is wrong. See the ';' on the end of integrate_modify_modifications; <-- Is wrong
and there were a lot of other errors too, Once I took out the errors and ran the hook again. Look at this.

This looks a lot better and I have more settings to add to this too. Kays, Thank you very Much.

That's 3 I owe you.


SMF Forums http://www.df-barracks.com Where gamers go.

Kays

Great, glad that did it. :)

Yep, it's the little things which can mess you up.

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Advertisement: