31
Mamba
Re: How to write an standard module for xoops (div table, pagination , sort, order)
  • 2013/10/6 0:24

  • Mamba

  • Moderator

  • Posts: 11366

  • Since: 2004/4/23


@ Irmtfan:
Quote:
good suggestions Mamba.
Im totally agree with using this:

$modversion['icons16']        = '../../Frameworks/moduleclasses/icons/16'
$modversion['icons32']        = '../../Frameworks/moduleclasses/icons/32'
;

Well, it looks like we need go the way you originally proposed, i.e. to have in xoops_version.php:

$modversion['dirmoduleadmin']   = 'Frameworks/moduleclasses'
$modversion['icons16']          = 'Frameworks/moduleclasses/icons/16'
$modversion['icons32']          = 'Frameworks/moduleclasses/icons/32';


And in menu.php something like this:

$module_handler xoops_gethandler('module');
$module $module_handler->getByDirname(basename(dirname(dirname(__FILE__))));
$pathIcon32 '../../' $module->getInfo('icons32');

xoops_loadLanguage('modinfo'$module->dirname());

$adminmenu = array();
$i=0;
$adminmenu[$i]["title"] = _MI_WFDOWNLOADS_MENU_HOME;
$adminmenu[$i]['link'] = "admin/index.php";
$adminmenu[$i]["icon"]  = $pathIcon32 '/home.png';
$i++;
...

And in /admin/admin_header.php we would have:

global $xoopsModule;
$pathIcon16 XOOPS_URL '/' $xoopsModule->getInfo('icons16');
$pathIcon32 XOOPS_URL '/' $xoopsModule->getInfo('icons32');
$pathModuleAdmin XOOPS_ROOT_PATH '/' $xoopsModule->getInfo('dirmoduleadmin');


The here defined $pathIcon16 and $pathIcon32 would be then used throughout the whole module.

And in the same way we'll define $pathIcon16 and $pathIcon32 in blocks, i.e.

$pathIcon16 XOOPS_URL '/' $xoopsModule->getInfo('icons16');
$pathIcon32 XOOPS_URL '/' $xoopsModule->getInfo('icons32');


Last week I was working on the "Latest News Block" module and I wanted to use the icons defined in the module the way as I was using them so far, however I couldn't use the variable that way - XOOPS doesn't see a link in a block as an "absolute module link", i.e. that that regardless where the block is, on the front page, or in the module view, the link should stay the same because it is owned by the module. Instead, XOOPS takes the links as relative to the root, so therefore I needed to adjust my thinking and change the scheme

It's not an issue - with this approach we'll have the same consistent way applied in modules and in blocks, just instead of being "module-centric" as it was thus far, the links will be now "root-centric".

Of course, in XOOPS 2.6.0 this will become no issue, because we'll have a direct link to the "media" repository, and XOOPS will find its way there automatically.
Support XOOPS => DONATE
Use 2.5.10 | Docs | Modules | Bugs

32
Mamba
Re: How to write an standard module for xoops (div table, pagination , sort, order)
  • 2013/10/6 0:32

  • Mamba

  • Moderator

  • Posts: 11366

  • Since: 2004/4/23


Quote:
1- About plugins:
IMO 2.5.x modules should (or at least can) follow 2.6 plugin structure.
If we think and we accept 2.6 is the future of xoops we should follow its ways for anything (here plugins)

Yes, you're absolutely right! We need to start using more and more the XOOPS 2.6.0 way of doing things as part of getting ready for migration.

That was the whole idea behind using Trabis' XMF (XOOPS Module Framework) by Richard as a "migration vehicle" from XOOPS 2.5.x to 2.6.0.

I think, Richard will be releasing the XMF Alpha in the near future, so we'll be able to play with and provide him with feedback, and then start on converting existing modules.

And as you said, we also need to use and promote the usage of XoopsFilterInput and the Request classes. I assume, they will be one way or the other part of XMF, so this should make everything much easier.

It's going to be fun
Support XOOPS => DONATE
Use 2.5.10 | Docs | Modules | Bugs

33
Mamba
Re: How to write an standard module for xoops (div table, pagination , sort, order)
  • 2013/10/6 2:42

  • Mamba

  • Moderator

  • Posts: 11366

  • Since: 2004/4/23


I was always wondering why we use HTML instead of TPL for Smarty templates.

I was recently reading this post from Wizanda, who was wondering about the same thing few years ago.

I would like to suggest that we go back to TPL, so we know exactly which is a Smarty Template, and which is a HTML file being used.

How are our designers feeling about it? I tested it in various HTML editors, and there was no difference how the files were handled.

Support XOOPS => DONATE
Use 2.5.10 | Docs | Modules | Bugs

34
irmtfan
Re: How to write an standard module for xoops (div table, pagination , sort, order)
  • 2013/10/10 3:12

  • irmtfan

  • Module Developer

  • Posts: 3419

  • Since: 2003/12/7


Quote:

however I couldn't use the variable that way - XOOPS doesn't see a link in a block as an "absolute module link"

Huum why not use this in xoops_version.php ?
$modversion['dirmoduleadmin']   = XOOPS_ROOT_PATH '/' 'Frameworks/moduleclasses'
$modversion['icons16']          = XOOPS_URL '/' 'Frameworks/moduleclasses/icons/16'
$modversion['icons32']          = XOOPS_URL '/' 'Frameworks/moduleclasses/icons/32';


Quote:

I would like to suggest that we go back to TPL, so we know exactly which is a Smarty Template, and which is a HTML file being used.

That is just a name and as always IMO names are not important. We can call them anything
But anyway we dont have any pure Smarty Template in modules. we have a mixture of html and smarty.
So maybe we can call it .htpl

About plugins I like to explain more:
I add the 2.6 plugin system in userlog but i also add another feature to find plugins in both locations:
1- modules/{$dirname}/class/plugin/{$pluginName}.php
2- modules/{$pluginName}/class/plugin/{$dirname}.php

so for example to find the newbb plugin for userlog module it will search with this priority:
1- modules/newbb/class/plugin/userlog.php
2- modules/userlog/class/plugin/newbb.php

we can change current tag module to have this plugin system very easy.

35
redheadedrod
Re: How to write an standard module for xoops (div table, pagination , sort, order)

When writing modules for Xoops I wanted to mention a good coding practice. With the advent of PHP 5 we have decent support for Objects and as module developers we should be making extensive use of them.

Within the module code there should be no direct calls to any of the Xoops or library API code. You should build classes for your module that extends classes that already exist in the API or build other classes to build a Xoops wrapper for your module. Then within your module make sure you only call your class functions.

The main reason for doing this is to upgrade your module when the API changes or if things need to be upgraded down the road. If you put all of your code into module classes that interfaces into Xoops or other libraries it makes it MUCH simpler to make changes later.

Rodney


36
chco2
Re: How to write an standard module for xoops (div table, pagination , sort, order)
  • 2013/10/24 23:41

  • chco2

  • Module Developer

  • Posts: 374

  • Since: 2004/3/5 1


That is the way to go. Unfortunately writing classes drops a big percentage of (semi-)module developers. Classes aren't very difficult, but we should make hands-on examples, practical, on how to do this. And show that it isn't as hard as people think.
I also practice 2 much direct calls just to make my code easier to read, with classes, most of the times, you need to know how they work and what they are there for. And finding time is one of my biggest efforts. And after an intermission remembering the calls that need to be made.

Just my 2 cents ..

37
redheadedrod
Re: How to write an standard module for xoops (div table, pagination , sort, order)

I understand chco2 I am in programming classes now and it is obvious to me how much easier things are to update with classes than procedural coding.

Perhaps some examples would help out. But yes object orientated is much nicer when it is used but there is a learning curve on them. (One of my instructors told me that a standard procedural programmer can take up to 5 years to get the full understanding of object and how they work.)

I have been using them for about 3-4 years now and I am almost there. But they are much easier to maintain. We only use classes/objects in my Java class.

38
Mamba
Re: How to write an standard module for xoops (div table, pagination , sort, order)
  • 2013/10/27 1:12

  • Mamba

  • Moderator

  • Posts: 11366

  • Since: 2004/4/23


Quote:
Perhaps some examples would help out.

Could you write a short tutorial on this?

That would be very helpful!
Support XOOPS => DONATE
Use 2.5.10 | Docs | Modules | Bugs

39
redheadedrod
Re: How to write an standard module for xoops (div table, pagination , sort, order)

I will see what I can do. It is hard to take a subject that takes a series of books to explain and make it into a short tutorial but I can at least setup a primer to allow people to understand why Objects are good to use.


40
chco2
Re: How to write an standard module for xoops (div table, pagination , sort, order)
  • 2013/10/27 9:09

  • chco2

  • Module Developer

  • Posts: 374

  • Since: 2004/3/5 1


If you could make a simple example (or some simple examples) related to XOOPS, I think I have a really nice guide lying around that explains the concept of classes, so I'll see if I can whip it into something we can use here.

Login

Who's Online

182 user(s) are online (106 user(s) are browsing Support Forums)


Members: 0


Guests: 182


more...

Donat-O-Meter

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

Latest GitHub Commits