1
Monika
Adding extra Blocks to a module
  • 2009/1/11 16:50

  • Monika

  • Not too shy to talk

  • Posts: 103

  • Since: 2008/12/19


Hello friends,

I would like to add 3 blocks to this module
Dictionary 0.91 created on 2004.

Currently it has only one block: Last definitions

I want to add:

Popular definitions

Random definitions

Requested definions.


Thank you in advance

2
ghia
Re: Adding extra Blocks to a module
  • 2009/1/11 18:44

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


In xoops_version.php add blocks by copying the block definition, renumbering them and renaming block_new to block_pop, block_rand and block_req. You can make use of the same option and template.
Add also the required title and description definitions to the language file.
Copy the block php file and rename it as in the definitions.
Adapt the where and order clause of the SQL statement to get the required records.


3
Monika
Re: Adding extra Blocks to a module
  • 2009/1/12 17:28

  • Monika

  • Not too shy to talk

  • Posts: 103

  • Since: 2008/12/19


Quote:
In xoops_version.php add blocks by copying the block definition, renumbering them and renaming block_new to block_pop, block_rand and block_req. You can make use of the same option and template.
Add also the required title and description definitions to the language file.
Copy the block php file and rename it as in the definitions.
Adapt the where and order clause of the SQL statement to get the required records.


Thank you Mr. Ghia, I followed your instructions but i didn't understand the last one, I don't know how to adapt the where and order clause of the SQL statement.

Let's see for example dictionary_block_pop.php

function dictionary_show_new($options) {
    global 
$xoopsDB;
    
$block = array();
    
$numDef $options[0];
    
    
$result $xoopsDB->queryF("SELECT id, name FROM ".$xoopsDB->prefix("dictionary")."  WHERE state='O' order by id desc LIMIT 0, $numDef");
    while(
$dic_def $xoopsDB->fetcharray($result)) {
        
$def = array();
        
$def['id'] = $dic_def['id'];
        
$def['name'] = $dic_def['name'];
        
$block['def'][] = $def;
    }
        return 
$block;
}

function 
numDef_edit($options) {
    
$form  "";
    
$form .= ""._MB_DIC_NUMSDEF."";
    
$form .= ".$options[0]."'>";
    
$form .= "";
    
$form .= "";
    return 
$form;
}
?>



I created block_pop.php, block_rand.php and block_req.php, Could you please tell me how to adapt them?


Cheers,

4
ghia
Re: Adding extra Blocks to a module
  • 2009/1/12 23:26

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


You need to change this statement:
$result $xoopsDB->queryF("SELECT id, name FROM ".$xoopsDB->prefix("dictionary")."  WHERE state='O' order by id desc LIMIT 0, $numDef");

This is now ordered by id number backwards (desc) and this mean the latest ones.
For random it is easy:
$result $xoopsDB->queryF("SELECT id, name FROM ".$xoopsDB->prefix("dictionary")."  WHERE state='O' order by RAND() LIMIT 0, $numDef");

For requested you have to know which field is used in the table to indicate that. Supposing it is when state = 1 then you have:
$result $xoopsDB->queryF("SELECT id, name FROM ".$xoopsDB->prefix("dictionary")."  WHERE state='1' order by id desc LIMIT 0, $numDef");

If it is another field eg. named req and with 1 in it then it would be:
$result $xoopsDB->queryF("SELECT id, name FROM ".$xoopsDB->prefix("dictionary")."  WHERE state='O' AND req = '1' order by id desc LIMIT 0, $numDef");
For popularity you have to know which field has the number of views or something and then you order on it:
$result $xoopsDB->queryF("SELECT id, name FROM ".$xoopsDB->prefix("dictionary")."  WHERE state='O' order by views desc LIMIT 0, $numDef");

I don't know the module and what is in the database, so you have to have a peek with phpMyAdmin (browse).
There you can also test your adapted SQL statements:
SELECT idname FROM yourxoopsprefix_dictionary WHERE state='O' order by id desc LIMIT 010);
(yourxoopsprefix is to be modified to the real used prefix of your database)

5
Monika
Re: Adding extra Blocks to a module
  • 2009/1/13 2:57

  • Monika

  • Not too shy to talk

  • Posts: 103

  • Since: 2008/12/19


Mr Ghia thank you so much for your efforts and detailed explanation, but unfortunately this module is not compatible with v 2.3.2, even if i add definitions, it always shows the message "The database is empty".

As far as the database is concerned, i couldn't find any fields that may affect those added blocks.

I hope this module will be updated soon, as it hasn't been updated since 2004 besides its author is anonymous

Thank you in advance.

6
Anonymous
Re: Adding extra Blocks to a module
  • 2009/1/14 0:14

  • Anonymous

  • Posts: 0

  • Since:


Hello,

Dictionary 0.91 is not last version, there are version 1.13 of this module here.

I fixed blocksadmin and other files in ver 1.13 to work with XOOPS 2.3.x, also it is compatible with PHP5 now and random definitions block added.

Click here to download dictionary 1.13 fix.

Note: All security holes was founded in version 0.91, 0.94 and 1.0 fixed by developer of this module, and he is correct english lang too.

7
Anonymous
Re: Adding extra Blocks to a module
  • 2009/1/14 0:18

  • Anonymous

  • Posts: 0

  • Since:


Sorry, but I think print.php sql injection not fixed in 1.13, other are fixed.

8
Monika
Re: Adding extra Blocks to a module
  • 2009/1/14 11:23

  • Monika

  • Not too shy to talk

  • Posts: 103

  • Since: 2008/12/19


Thank you Mr. Mowaffak for being quick at fixing its bugs, but I still have the same problem: I can't add definitions !!!?? It always shows The database is empty!

I use XOOPS 2.3.2b php5

I tested it on a fresh XOOPS install too.

9
Anonymous
Re: Adding extra Blocks to a module
  • 2009/1/14 14:09

  • Anonymous

  • Posts: 0

  • Since:


It is working for me.

Is register globals OFF or ON ?

Login

Who's Online

349 user(s) are online (223 user(s) are browsing Support Forums)


Members: 0


Guests: 349


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits