phpBB2Refugees.com Logo
Not affiliated with or endorsed by the phpBB Group

Register •  Login 

Continue the legacy...

Welcome to all phpBB2 Refugees!Wave Smilie

This site is intended to continue support for the legacy 2.x line of the phpBB2 bulletin board package. If you are a fan of phpBB2, please, by all means register, post, and help us out by offering your suggestions. We are primarily a community and support network. Our secondary goal is to provide a phpBB2 MOD Author and Styles area.

NulAvatar Categories [DEV]


 
Search this topic... | Search MOD Writing... | Search Box
Register or Login to Post    Index » MOD Writing  Previous TopicPrint TopicNext Topic
Author Message
Acaria
Board Member



Joined: 20 Feb 2009

Posts: 238



PostPosted: Thu Jun 10, 2010 7:52 am 
Post subject: NulAvatar Categories [DEV]

I've been working on a "category" addon for NulAvatar for the past few days. I thought I'd go ahead and post what I have so people can help me out with it. I'm sure I've done some things that can be made a lot better. XD

Here's where my code stands:

First you'll need to run this SQL:
Code:
CREATE TABLE IF NOT EXISTS `phpbb_nulavatar_tabs` (
  `id` int(10) NOT NULL auto_increment,
  `name` mediumtext NOT NULL,
  `position` int(3) NOT NULL,
  PRIMARY KEY  (`id`)
)
ALTER TABLE `phpbb_nulavatar_images` ADD `tab2` INT( 10 ) NOT NULL AFTER `layer`


Here's what I have for the front-end. I'm using jQuery and the jQuery Tabs UI to give it a good look. In all honesty, this could be redone, but the code (as it stands) works so perfectly, I don't want to change it. It's pretty awesome for just having to link to 3 files. icon_razz.gif

Okay, so it assembles the amount of tabs, arranges them by the order you wish, then when you click one, it calls all items assigned to that tab via AJAX. This will reduce initial page load time, as I've noticed that's a serious problem when you start having numerous items in your system.
Code:
<html>
<head>
   <title> Testing out Tab Stuff </title>
   <link href="tabs.css" rel="stylesheet" type="text/css"/>
   <script src="jquery.min.js"></script>
   <script src="jquery_tabs.js"></script>
   <script>
   $(document).ready(function() {
      $("#tabs").tabs();
   });
   </script>
</head>
<body style="font-size:62.5%;">

<div id="tabs">
<?php

$conn = mysql_connect("localhost", "", ""); mysql_select_db('', $conn);

$data = array();
$sql = "SELECT id, name, position FROM phpbb_nulavatar_tabs ORDER BY position";
if($result = mysql_query($sql)){
    if(mysql_num_rows($result) > 0){
        echo "<ul>\n";
        while($rows = mysql_fetch_assoc($result)){
            echo "<li><a href=\"tabs_select.php?tab=" . $rows['id'] . "\"><span>" . $rows['name'] . "</span></a></li>\n";
            $data[$rows['id']] = $rows['name'];
        }
        echo "</ul>\n";
    }
    else{
        echo "No layers detected.";
    }
}
else{
    echo "There was an error.";
}

?>
</div>

</body>
</html>


And here's the page that is called when you click a tab. No security added yet, but that's because I'm focusing on getting it to work. Basically just assembles images. Simple enough. Code is probably not what it should be; I just copied from the front-end because it worked. XD
Code:
<?php

$conn = mysql_connect("localhost", "", ""); mysql_select_db('circe_data', $conn);

if (isset($_GET['tab'])) {
   $item_id = $_GET['tab'];
   $sql = "SELECT image FROM phpbb_nulavatar_images WHERE tab = $item_id";
   $result = mysql_query($sql);
      if ( mysql_num_rows($result) <= 0 ) {
         echo "No items to display.";
      }
      else {
         $data = array();
           while($rows = mysql_fetch_assoc($result)){
            echo "<img src=\"phpBB2/images/nulavatar/" . $rows['image'] . "\">\n";
            $data2[$rows['id']] = $rows['image'];
         }
      }
}
else {
   echo "No tab id selected.";
}

?>


And here's a little install guide I made for edits to the admin_nulavatar.php file. This was surprisingly simple; just copypasta'd the existing code. :3

Yes, the addition of an extra SQL is not good. I tried making it one SQL query, but I kept getting an error. I'll fix that later on.

If this doesn't work, post your admin_nulavatar.php file and the error. I may have forgotten something in the install file. >.<
Code:
#
#-----[ OPEN ]------------------------------------------
#
admin/admin_nulavatar.php

#
#-----[ FIND ]------------------------------------------
#
   $sql = "SELECT * FROM ".$table_prefix."nulavatar_layers ORDER BY position DESC";
   
#
#-----[ AFTER, ADD ]------------------------------------------
#
   $sql2 = "SELECT * FROM ".$table_prefix."nulavatar_tabs ORDER BY position DESC";
   
#
#-----[ FIND ]------------------------------------------
#
if ( !($result = $db->sql_query($sql)) )
   { message_die(GENERAL_MESSAGE, "<b>Fatal Error!</b><br />".mysql_error()); }

   $l_list = '';

#
#-----[ FIND, IN-LINE ]------------------------------------------
#
if ( !($result = $db->sql_query($sql))

#
#-----[ AFTER, ADD ]------------------------------------------
#
|| !($result2 = $db->sql_query($sql2))

#
#-----[ FIND ]------------------------------------------
#
   $l_list = '';

   for( $i = 0; $i < mysql_num_rows($result); $i++ )
   {
      $row = mysql_fetch_array($result);
      $l_list .= '<option value = "'.$row['id'].'">'.str_replace("_"," ",$row['name']).'</option>';
   }

#
#-----[ AFTER, ADD ]------------------------------------------
#
   $t_list = '';

   for( $ii = 0; $ii < mysql_num_rows($result2); $ii++ )
   {
      $row2 = mysql_fetch_array($result2);
      $t_list .= '<option value = "'.$row2['id'].'">'.str_replace("_"," ",$row2['name']).'</option>';
   }

#
#-----[ FIND ]------------------------------------------
#
               <tr>
                  <td width="40%" class="row2"><span class="gen"><b>'.$lang['nulavatar_layer'].'</b></span></td>
                  <td width="60%" class="row2"><span class="gen"><select name="layer">'.$l_list.'</select></span></td>
               </tr>
               
#
#-----[ AFTER, ADD ]------------------------------------------
#
               <tr>
                  <td width="40%" class="row2"><span class="gen"><b>Tab</b></span></td>
                  <td width="60%" class="row2"><span class="gen"><select name="tab">'.$t_list.'</select></span></td>
               </tr>

#
#-----[ FIND ]------------------------------------------
#
if(($name == "") OR ($image == "") OR ($layer == "")

#
#-----[ AFTER, ADD ]------------------------------------------
#
OR ($tab == "")

#
#-----[ FIND ]------------------------------------------
#
   $sql = "INSERT INTO `".$table_prefix."nulavatar_images` (name,image,layer,itemneeded,dontshowlayer) VALUES ('".$name."','".$image."','".$layer."','".$itemneeded."','".$dontshowlayer."')";

#
#-----[ REPLACE WITH ]------------------------------------------
#
   $sql = "INSERT INTO `".$table_prefix."nulavatar_images` (name,image,layer,tab,itemneeded,dontshowlayer) VALUES ('".$name."','".$image."','".$layer."','".$tab."','".$itemneeded."','".$dontshowlayer."')";


And that's all I have right now. Feel free to post your comments, suggestions, updates, etc. All is welcome! :3


[ Edit ] It should also be noted I'll be (hopefully) be fixing up a bunch of the problems NulAvatar presents. My main goal is to reduce the innumerable amount of queries to something much more manageable (I'm shooting for 5 to 6, and thats from drawing items to saving). Having 9000 queries on one page is not just silly, it's incredibly horrible design.
Back to top
Holger
Board Member



Joined: 19 Jan 2009

Posts: 509
Location: Hanover


flag
PostPosted: Thu Jun 10, 2010 9:35 am 
Post subject: Re: NulAvatar Categories [DEV]

Sorry! What does that do? Screenshots? icon_redface.gif
Back to top
StarWolf3000
Board Member



Joined: 10 Jun 2010

Posts: 97
Location: Germany


flag
PostPosted: Thu Jun 10, 2010 9:46 am 
Post subject: Re: NulAvatar Categories [DEV]

Looks like this adds a Tab System to the NulAvatar MOD, using jQuery.

Maybe for navigating through the dynamic avatars made with the MOD itself or the template images used by the MOD.

NulAvatar itself can be used to create dynamic avatars, similar to phpBB Scripts creating dynamic signature pictures.

Ah, and this is my first post here.
Back to top
Holger
Board Member



Joined: 19 Jan 2009

Posts: 509
Location: Hanover


flag
PostPosted: Thu Jun 10, 2010 9:55 am 
Post subject: Re: NulAvatar Categories [DEV]

Welcome! Willkommen!
And thanks for the brief explanation.
Back to top
Acaria
Board Member



Joined: 20 Feb 2009

Posts: 238



PostPosted: Thu Jun 10, 2010 10:04 am 
Post subject: Re: NulAvatar Categories [DEV]

Here's a demo I have up

Basically, NulAvatar gives you layers. Each layer attaches an item to a dynamic avatar. The problem is, each layer shows. This gets very, very cluttered when you have many layers. This update will primarily allow you to organize your layers into tabs.

So you could have layer 1, 2, and 3 under tab 1. Layers 4, 8, and 9 under tab 2. Then Layers 5, 6, and 7 in another.

It will hopefully increase functionality. Plus, it's an addon I've seen (and have myself) requested for years now. Time for someone to finally do this.

I'll also be getting at a number of NulAvatar's other great fallacies, but those will come after.
Back to top
Holger
Board Member



Joined: 19 Jan 2009

Posts: 509
Location: Hanover


flag
PostPosted: Thu Jun 10, 2010 10:05 am 
Post subject: Re: NulAvatar Categories [DEV]

Nice one! icon_biggrin.gif
Back to top
Display posts from previous:   
Register or Login to Post    Index » MOD Writing  Previous TopicPrint TopicNext Topic
Page 1 of 1 All times are GMT
 
Jump to:  

Index • About • FAQ • Rules • Privacy • Search •  Register •  Login 
Not affiliated with or endorsed by the phpBB Group
Powered by phpBB2 © phpBB Group
Generated in 0.0275 seconds using 15 queries. (SQL 0.0015 Parse 0.0009 Other 0.0252)
phpBB Customizations by the phpBBDoctor.com
Template Design by DeLFlo and MomentsOfLight.com Moments of Light Logo