Subject:*
<
Name/Email:*
<
Message Icon:*
<
Select*
<
Message:*
<



Click the Preview to see the content in action.
Options:*
<
Confirmation Code*
<
5 - 3 = ?  
Input the result from the expression
Maximum attempts you can try: 10
*
<
     
MODULE_X is the helper class for module x.(module x can be the module itself) The above is without hard-code and very understandable for everybody. Then I like to discuss about your special need and your exampled code(which is off-topic so maybe it is better to be in another topic :D): Side note 1: I dont know these codes you wrote comes from what module? but they are not good. One can do this without JOIN by enhancing that [b]Easy way[/b] :D [quote] For example: displays list articles with category names. Easy way: 1 - read articles from database by using article class 2 - for every article object do access to database by using category class [/quote] why do you (or that module developer) think you cannot follow that easy way more effective and with much less codes than the JOIN way? It can be done just by [b]two queries.[/b] 1 - read articles from database by using article handler class [code] SELECT * FROM {$this->table} [/code] 2- for [b]all above article category Ids[/b] do access to database by using category handler class. [code] SELECT category_id, category_name FROM {$this->table} WHERE category_id IN {$articles_category_id} [/code] which $articles_category_id is all category ids you get from the first query. To implement the above you even dont need to write special function (function &getObjects($args)) :D All can be done in front side :D I commented the below code for you to see how it can be done with ease :D [code] $articleH = xoops_getmodulehandler('article', 'MODULE'); $categoryH = xoops_getmodulehandler('category', 'MODULE'); $criteriaArticle = new CriteriaCompo(); // continue your criteria here for $criteriaArticle // ... // START first query for articles // remember getAll($criteria = null, $fields = null, $asObject = true, $id_as_key = true) $articleObjs = $articleH->getAll($criteriaArticle); // END first query for articles $articles_category_id = array(); foreach ($articleObjs as $artObj) { $articles_category_id[] = $artObj->getVar("category_id"); // you can do any other thing here with articles!!! // ... } // START second query for category names $criteriaCat = new CriteriaCompo(); $criteriaCat->add(new Criteria("category_id", "(" . implode(", ", $articles_category_id) . ")", "IN"), "AND"); // you can add what fields you need here :D $catFields = array("category_id","category_name"); $catNames = $categoryH->getAll($criteriaCat, $catFields, false); // END second query for category names // FINISH!!! // usage: $catNames[$artObj->getVar("category_id")]["category_name"] [/code] As i said before the above code is: 1- most effective code to do the job (more than JOIN) 2 simple queries are better than one query with JOIN. 2- no need to write any code in the handler class :D 3- can be extend very easy. eg: if you need category_created time you can add the field. Side note 2: Anyway IMO your query will not work because you didnt add db prefix: instead of: [code] mymodule_article [/code] you have to use: [code] $this->db->prefix('mymodule_article') [/code] but using hadlers and helper class you will not need to think about such a annoying thing (like i must add prefix here or not) :D Side note 3: If you are very tight for using only one query you should add one field category_name to articles table. [code] //need add initVar('category_name') to Article class [/code] As the above comment after your query suggested, If you really need to display the category name alongside an article in [b]many links of your module[/b] it is better to add another field called "category_name" in mymodule_article table. But generally you dont need that and i dont advise it:D [/quote]" />

Re: How to write an standard module for xoops (div table, pagination , sort, order)
by bumciach on 2013/10/28 10:48:41

Quote:

irmtfan wrote:

Huum why not use this in xoops_version.php ?
le="color: #000000"><?php $modversion['dirmoduleadmin'] = XOOPS_ROOT_PATH . '/' . 'Frameworks/moduleclasses'; $modversion['icons16'] = XOOPS_URL . '/' . 'Frameworks/moduleclasses/icons/16'; $modversion['icons32'] = XOOPS_URL . '/' . 'Frameworks/moduleclasses/icons/32';



+1


And about my experience with Objects. For me the best topic was
https://xoops.org/modules/newbb/viewtopic.php?viewmode=flat&type=&topic_id=68782&forum=28
Trabis explanation was excellent and helped me a lot in understanding how the xoopsobject works. Thus after that I had more easy in analise rest of classes like:
https://xoops.org/modules/newbb/viewtopic.php?viewmode=flat&type=&topic_id=69368&forum=4
And also analysis of Catzwolf work helped in understanding how to use objects into xoops module - his modules code was very simple (too very simplified so sometimes multiplicate sql query though). But those codes are very old so should consider other examples.
Re: How to write an standard module for xoops (div table, pagination , sort, order)
by chco2 on 2013/10/27 9:09:45

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.
Re: How to write an standard module for xoops (div table, pagination , sort, order)
by redheadedrod on 2013/10/27 8:03:50

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.

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

Quote:
Perhaps some examples would help out.

Could you write a short tutorial on this?

That would be very helpful!
Re: How to write an standard module for xoops (div table, pagination , sort, order)
by redheadedrod on 2013/10/25 12:09:32

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.

Who's Online

171 user(s) are online (139 user(s) are browsing Support Forums)


Members: 0


Guests: 171


more...

Donat-O-Meter

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

Latest GitHub Commits