Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Catalog System
Author Message
TomNook08
Member


Posts: 52
Joined: Mar 2009
Reputation: 0
Post: #1
 Catalog System
I have an idea in my head for a Catalog system/plugin but I don't know where to start...Here is what I want it to do:
  • Add Items from the game Animal Crossing to users profile.
  • 3 categories (since their are 3 AC games)
  • Once you click a category it shows the items
  • Then you click 1 of 2 buttons (Want or Own)

Does that make sense? XD

I really want to learn to create plugins/mods and again I just don't know where to start :(

I'm an Animal Crossing Fanatic!!!
(Nintendo's Famous Game)
03-10-2009 03:16 AM
Nickman
Manager



Posts: 1,360
Joined: May 2008
Reputation: 30
Post: #2
RE: Catalog System
I would say you should start by gaining a knowledge of PHP. If you have that, then I suggest browsing through different plugins and see how they work.



Playstation Forums | Hoodrat Arcade | Tech news at a glance | BestVidz.net | AdminSpace: Where admins talk | Download'en
03-10-2009 06:54 AM


TomNook08
Member


Posts: 52
Joined: Mar 2009
Reputation: 0
Post: #3
RE: Catalog System
Ok Thanks and I know some of the basics of PHP XD

I'm an Animal Crossing Fanatic!!!
(Nintendo's Famous Game)
03-10-2009 08:57 AM
TomNook08
Member


Posts: 52
Joined: Mar 2009
Reputation: 0
Post: #4
RE: Catalog System
Sorry to double post but is this right?

I am a complete newb at the Mybb plugin creation xP

PHP Code:
<?
/**
 *    Plugin Copyright
 *    TomNook08 of MyBBSource  
 */
 
if(!defined("IN_MYBB")) {
    die(
"This file cannot be accessed directly.");
}
//Add Your Hooks
$plugins->add_hook("HOOK NAME""FUNCTION_NAME");

//REQUIRED
function catalog_info()
{
    return array(
        
'name'            => 'Item Catalog',
        
'description'    => 'Adds Items from the Animal Crossing games to the users profile.',
        
'website'        => 'http://www.mybbsource.com',
        
'author'        => 'TomNook08',
        
'authorsite'    => 'http://www.animalcrossingcentral.com',
        
'version'        => '1.0',
    );
}

function 
catalog_activate() {
   global 
$db;
   
   require 
MYBB_ROOT.'/inc/adminfunctions_templates.php';
find_replace_templatesets("header"'#'.preg_quote('</li>').'#''<li>hi</li></ul>');
//stuff to do on activation of the plugin
}
function 
catalog_deactive()
{
global 
$db;

    require 
MYBB_ROOT.'/inc/adminfunctions_templates.php';
find_replace_templatesets("header"'#'.preg_quote('<li>hi</li></ul>').'#''</ul>'0);
}

function 
FUNCTION_NAME() {
    global 
$mybb,$db,$lang;
//DO SOMETHING WHEN THE HOOK IS CALLED
}


?>

I'm an Animal Crossing Fanatic!!!
(Nintendo's Famous Game)
03-12-2009 08:43 AM


Nickman
Manager



Posts: 1,360
Joined: May 2008
Reputation: 30
Post: #5
RE: Catalog System
(03-12-2009 08:43 AM)TomNook08 Wrote:  Sorry to double post but is this right?

I am a complete newb at the Mybb plugin creation xP

PHP Code:
<?
/**
 *    Plugin Copyright
 *    TomNook08 of MyBBSource  
 */
 
if(!defined("IN_MYBB")) {
    die(
"This file cannot be accessed directly.");
}
//Add Your Hooks
$plugins->add_hook("HOOK NAME""FUNCTION_NAME");

//REQUIRED
function catalog_info()
{
    return array(
        
'name'            => 'Item Catalog',
        
'description'    => 'Adds Items from the Animal Crossing games to the users profile.',
        
'website'        => 'http://www.mybbsource.com',
        
'author'        => 'TomNook08',
        
'authorsite'    => 'http://www.animalcrossingcentral.com',
        
'version'        => '1.0',
    );
}

function 
catalog_activate() {
   global 
$db;
   
   require 
MYBB_ROOT.'/inc/adminfunctions_templates.php';
find_replace_templatesets("header"'#'.preg_quote('</li>').'#''<li>hi</li></ul>');
//stuff to do on activation of the plugin
}
function 
catalog_deactive()
{
global 
$db;

    require 
MYBB_ROOT.'/inc/adminfunctions_templates.php';
find_replace_templatesets("header"'#'.preg_quote('<li>hi</li></ul>').'#''</ul>'0);
}

function 
FUNCTION_NAME() {
    global 
$mybb,$db,$lang;
//DO SOMETHING WHEN THE HOOK IS CALLED
}


?>
Looks about right. Are you getting any issues or something?



Playstation Forums | Hoodrat Arcade | Tech news at a glance | BestVidz.net | AdminSpace: Where admins talk | Download'en
03-12-2009 09:12 AM
TomNook08
Member


Posts: 52
Joined: Mar 2009
Reputation: 0
Post: #6
RE: Catalog System
Quote:Looks about right. Are you getting any issues or something?

No but what do I put where it says hook name and function name
PHP Code:
$plugins->add_hook("HOOK NAME""FUNCTION_NAME"); 

I have studied plugins over and over...I am just really new at this and its my first plugin :P

I'm an Animal Crossing Fanatic!!!
(Nintendo's Famous Game)
03-12-2009 12:44 PM


Nickman
Manager



Posts: 1,360
Joined: May 2008
Reputation: 30
Post: #7
RE: Catalog System
(03-12-2009 12:44 PM)TomNook08 Wrote:  
Quote:Looks about right. Are you getting any issues or something?

No but what do I put where it says hook name and function name
PHP Code:
$plugins->add_hook("HOOK NAME""FUNCTION_NAME"); 

I have studied plugins over and over...I am just really new at this and its my first plugin :P

HOOK NAME is the hook found where you want to run your function. So if you want your plugin to run on every page, you might want to use global_end. FUNCTION_NAME is your own custom function.



Playstation Forums | Hoodrat Arcade | Tech news at a glance | BestVidz.net | AdminSpace: Where admins talk | Download'en
03-12-2009 12:46 PM
TomNook08
Member


Posts: 52
Joined: Mar 2009
Reputation: 0
Post: #8
RE: Catalog System
Oh ok Thank you so much :)

I'm an Animal Crossing Fanatic!!!
(Nintendo's Famous Game)
03-12-2009 12:48 PM


TomNook08
Member


Posts: 52
Joined: Mar 2009
Reputation: 0
Post: #9
RE: Catalog System
I just got my very first error
I attached a picture and here is the code...

PHP Code:
<?php
/**
 *    Plugin Copyright
 *    TomNook08 of MyBBSource  
 */

if(!defined("IN_MYBB")) {
    die(
"This file cannot be accessed directly.");
}
//Add Your Hooks
$plugins->add_hook("member_profile_end""Show_Catalog");

//REQUIRED
function catalog_info()
{
    return array(
        
'name'            => 'Item Catalog',
        
'description'    => 'Adds Items from the Animal Crossing games to the users profile.',
        
'website'        => 'http://www.mybbsource.com',
        
'author'        => 'TomNook08',
        
'authorsite'    => 'mailto:[email protected]',
        
'version'        => '1.0',
        
'compatibility'     =>    '14*',

    );
}

function 
catalog_activate() {
   global 
$db;
       
    
$catalog_admin = array(
        
'gid'            => 'NULL',
        
'name'            => 'catalogadmin',
        
'title'            => 'Catalog Admin',
        
'description'    => 'Settings For The Catalog System.',
        
'disporder'        => $rows+1,
        
'isdefault'        => 'no',
    );

    
$db->insert_query('settinggroups'$catalog_admin);
    
$gid $db->insert_id();

    
$catalog_setting_1 = array(
        
'sid'            => 'NULL',
        
'name'            => 'enablecatalog',
        
'title'            => 'Enable Catalog System?',
        
'description'    => 'If set to off, no one will get a catalog',
        
'optionscode'    => 'onoff',
        
'value'            => 'on',
        
'disporder'        => 1,
        
'gid'            => intval($gid),
    );

    
$catalog_setting_2 = array(
        
'sid'            => 'NULL',
        
'name'            => 'showwhichgames',
        
'title'            => 'Show Which Game',
        
'description'    => 'Set to 1 to show only ACGC items, 2 to show only ACWW items, 3 to show ACCF/LGTTC items, or 0 for all 3 games',
        
'optionscode'    => 'text',
        
'value'            => '0',
        
'disporder'        => 2,
        
'gid'            => intval($gid),
    );
    
$catalog_setting_3 = array(

        
'sid'            => 'NULL',
        
'name'            => 'adminitems',
        
'title'            => 'Admin Remove Items?',
        
'description'    => 'Do you want admins to be able to remove items?',
        
'optionscode'    => 'onoff',
        
'value'            => 'off',
        
'disporder'        => 3,
        
'gid'            => intval($gid),
    );
    
$db->query("CREATE TABLE `".TABLE_PREFIX."catalog` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`memberid` INT NOT NULL)"
);
    
$db->insert_query('settings'$catalog_setting_1);
    
$db->insert_query('settings'$catalog_setting_2);
    
$db->insert_query('settings'$catalog_setting_3);
    require 
MYBB_ROOT."/inc/adminfunctions_templates.php";
    
find_replace_templatesets("member_profile"'#{\$signature}#'"{\$signature}\n{\$catalog}");
    
$template = array(
        
"title"        => "catalog",
        
"template"    => "<head>
<title>{\$mybb->settings[\'bbname\']} - Catalog</title>
{\$headerinclude}
</head>
<body>
    {\$header}
    <table border=\"0\" cellspacing=\"{\$theme[\'borderwidth\']}\" cellpadding=\"{\$theme[\'tablespace\']}\" class=\"tborder\" style=\"clear: both;\">
        <tr>
            <td class=\"thead\"><strong>My Catalog</strong></td>
        </tr>
        <tr>
            <td class=\"trow1\"><br />
</td>
        </tr>
    </table>
    {\$footer}
</body>
</html>
"
,
        
"sid"        => -1
    
);
    
$db->insert_query("templates"$template);
//stuff to do on activation of the plugin
}
function 
catalog_deactive()
{
global 
$db;
$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name='catalogadmin'");
    
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN(
        'enablecatalog',
        'showwhichgames',
        'adminitems',
    )"
);
    
$db->query("DELETE FROM ".TABLE_PREFIX."templates WHERE title='catalog'");
    
$db->query("DROP TABLE ".TABLE_PREFIX."catalog");
    require 
MYBB_ROOT."/inc/adminfunctions_templates.php";
    
find_replace_templatesets("member_profile"'#{\$catalog}(\r?)(\n?)#'''0);
}

function 
Show_Catalog() {
    global 
$memprofile,$mybb,$theme,$db,$lang,$templates;
    
//DO SOMETHING WHEN THE HOOK IS CALLED
}


?>

  001.png (Size: 10.51 KB / Downloads: 13)

Oh perfect it stretched the page XD

I'm an Animal Crossing Fanatic!!!
(Nintendo's Famous Game)
(This post was last modified: 03-12-2009 11:46 PM by TomNook08.)
03-12-2009 11:46 PM
Splappy
New Custom User Title



Posts: 305
Joined: Oct 2008
Reputation: 5
Post: #10
RE: Catalog System
Try changing 'NULL' to just NULL without the single quotes in the whole code.

lolwhut? | follow meh on twitter. NAW.
03-13-2009 03:47 AM


 




New to MyBBSource?Need Assistance?
  • Mark Forums Read
  • View Forum Staff
  • Looking for a MyBB Host?

  



Theme created by AK-47. Find more great themes and skins at K! Dezign R1s.net