010 - Create a Joomla! 1.5 module listing all of the items in a given category

Google's Highly Open Participation Program tries to get young students into Open Source and Joomla! specifically. Everyone is welcome, there are not limits. You can be a coder, documenter, tester, translator to help out. Jump in and start helping!
User avatar
fealebenpae
Joomla! Intern
Joomla! Intern
Posts: 54
Joined: Fri Nov 30, 2007 8:33 pm
Location: Vidin, Bulgaria

010 - Create a Joomla! 1.5 module listing all of the items in a given category

Postby fealebenpae » Fri Nov 30, 2007 8:55 pm

Hey guys, my name is Yavor, I live in Bulgaria and I claimed this issue:

Create a Joomla! 1.5 module listing all of the items in a given category
Description

Content in Joomla! is organized into sections, categories and then articles.

The core of Joomla! 1.5 includes a module (sections) that lists and links
to each of the sections.

For this task you will create a module that lists and links to the
categories in each section.

The user should be able to pick a section and to select the type of links
(list or blog) that will be made to the categories.
Licensing

All code must be created using the GNU General Public License version 2.
http://www.gnu.org/licenses/old-license ... .html#SEC4
Skills Needed

Familiarity with Joomla! content structure and Joomla! modules

Knowledge of MySQL

Knowledge of php
Difficulty

Advanced
Work Product

A ready to install module package.
Extra Credit (optional)

Register your project at joomlacode.org and load your files there.

Submit your final version to the Joomla! Extensions Directory.

Respond to feedback from users.

Document your experience developing the module with a post in the Joomla!
101 forum.
Time Limit

4 Weeks


I've got the application logic all right, and even built an installable package. But what bugs me is that on a fresh RC3 installation with sample content loaded, some categories just plain refuse to display themselves with a blog layout (courtesy of attaching a "layout=blog" to the url) but if I create a menu entry for a blog view of that same category, it works. I'm studying the new com_content for a clue. I'll be uploading the code to Joomlacode the day after tomorrow, as tomorrow is SAT day.

P.S. It's great to be able to contribute to such a fantastic community!


[me=AmyStephen]Changed subject slightly for sorting all threads to match against Google resource  :)[/me]

Google Code Link

Task claimed: Nov 28 Due: Dec 26
Last edited by AmyStephen on Wed Dec 12, 2007 3:51 am, edited 1 time in total.
And it came to pass that in that time the Great God Om spake unto Brutha, the Chosen One: "Psst!"

kdevine
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 200
Joined: Thu Mar 02, 2006 8:38 pm
Location: Baltimore, MD

Re: 010 - Create a Joomla! 1.5 module listing all of the items in a given catego

Postby kdevine » Sat Dec 01, 2007 2:01 am

Yavor, when a menu item is created there are parameters available to define the layout of the page. So, when you try to dynamically build a URL in the module with a blog layout it is not loading the page parameters that a menu item would - there is no Itemid in the URL. Try working with the latest version of 1.5 from the SVN. It looks like this problem has been fixed by setting default parameters to give the blog layout even if the page is not loaded from a menu item.

User avatar
fealebenpae
Joomla! Intern
Joomla! Intern
Posts: 54
Joined: Fri Nov 30, 2007 8:33 pm
Location: Vidin, Bulgaria

Re: 010 - Create a Joomla! 1.5 module listing all of the items in a given catego

Postby fealebenpae » Sat Dec 01, 2007 3:02 pm

I just tested the module against the latest nightly build and it works like a charm. Thanks a stack for the suggestion. I've always been plagued by those pesky Itemids :)
And it came to pass that in that time the Great God Om spake unto Brutha, the Chosen One: "Psst!"

kdevine
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 200
Joined: Thu Mar 02, 2006 8:38 pm
Location: Baltimore, MD

Re: 010 - Create a Joomla! 1.5 module listing all of the items in a given catego

Postby kdevine » Sat Dec 01, 2007 4:15 pm

Good, glad it worked for you. If you have something complete you can post it here for comments before submitting it for review. If you are uploading to joomlacode just post a link to it here.

User avatar
fealebenpae
Joomla! Intern
Joomla! Intern
Posts: 54
Joined: Fri Nov 30, 2007 8:33 pm
Location: Vidin, Bulgaria

Re: 010 - Create a Joomla! 1.5 module listing all of the items in a given catego

Postby fealebenpae » Sat Dec 01, 2007 4:25 pm

Yeah, I've got a release  on joomlacode: http://joomlacode.org/gf/download/frsre ... gories.zip

I'm open to suggestions and such. I think it works ok, although I should investigate into caching as my current number of SQL queries is anything but desirable.
And it came to pass that in that time the Great God Om spake unto Brutha, the Chosen One: "Psst!"

User avatar
willebil
Joomla! Guru
Joomla! Guru
Posts: 764
Joined: Thu Aug 18, 2005 12:06 pm
Location: Netherlands

Re: 010 - Create a Joomla! 1.5 module listing all of the items in a given catego

Postby willebil » Sat Dec 01, 2007 4:52 pm

I have taken a close look to this results (looks already pretty good), the following comments:

- I was not able to install the package using the installer (latest trunk). Installed it manually (file copy + database module added).
- The code files miss a proper header containing the license information. Check the Joomla!code for a proper example.
- You can use more comments and use docbook markups for more easy documentation later on.
- Module class suffix is missing in the module properties, add it.

Additional bonus things you can consider incorporating in this module:
- Order option (check latestnews module for example)
- Caching support (see also latestnews)

User avatar
fealebenpae
Joomla! Intern
Joomla! Intern
Posts: 54
Joined: Fri Nov 30, 2007 8:33 pm
Location: Vidin, Bulgaria

Re: 010 - Create a Joomla! 1.5 module listing all of the items in a given catego

Postby fealebenpae » Sat Dec 01, 2007 6:01 pm

Thanks for your reply.

The package installed fine for me both on RC3 and the Nightly, although I used the FTP layer on the nightly and in both cases it threw chmod hiccups but that's because of my setup. I'd be very grateful if you can provide me with a specific error message so I can delve deeper into the issue.

I checked out the code examples and I've implemented the necessary headers, I think. It's all in SVN. I'll start commenting the code as soon as I'm happy with the functionality of the code.

The module class suffix shows up fine in properties for me, although I had to fix the code for it to be used. It's even in the XML, which I adapted from mod_latestnews.

Right now I'm using the DB ordering for each section/category, but I can add an option to sort them by newest articles.

I can implement caching by hand with JCache, but my test on RC3 shows that the module is successfully cached when caching is enabled in the global configuration. Caching seems to be broken in my Nightly, as it does now allow me to use the file method for caching, but that may be because of JFTP.

All right, I'll get to work.
And it came to pass that in that time the Great God Om spake unto Brutha, the Chosen One: "Psst!"

User avatar
mcsmom
Joomla! Exemplar
Joomla! Exemplar
Posts: 7985
Joined: Thu Aug 18, 2005 8:43 pm
Location: New York
Contact:

Re: 010 - Create a Joomla! 1.5 module listing all of the items in a given catego

Postby mcsmom » Sat Dec 01, 2007 6:10 pm

Wow you already have 9 downloads!
So we must fix our vision not merely on the negative expulsion of war, but upon the positive affirmation of peace. MLK 1964.
http://officialjoomlabook.com Get it at http://www.joomla.org/joomla-press-official-books.html Buy a book, support Joomla!.

kdevine
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 200
Joined: Thu Mar 02, 2006 8:38 pm
Location: Baltimore, MD

Re: 010 - Create a Joomla! 1.5 module listing all of the items in a given catego

Postby kdevine » Sat Dec 01, 2007 6:27 pm

The code looks good. I have just a few comments.

1. I was able to install the module, however, I was not able to create an instance of it in the module manager. I'm using the latest build from SVN and I guess something changed since RC3 because the hyphen you have in the module name is causing errors.

2. I would like to see you format your sql string like this...

Code: Select all

      $sec_query = 'SELECT id, title'
         . ' FROM #__sections'
         . ' WHERE published = 1'
         . ' AND access <= ' .(int) $aid
         . ($secid ? $secCondition : '')
         . ' ORDER BY ordering ASC'
         ;


I think it makes it easier for other developers to read it later.

3. Caching for this module worked fine.

4. I would like to see the paramters more clearly defined. The count option is a little misleading, heck is it even necessary?

I would prefer an option to choose how to link to the categories rather than getting both links (blog and list), an option to link the category titles or use a read more link, maybe a parameter to display the category description, or the number of articles like the section layout of the  content component. I realize that is a tall order - any of those would definitely be a bonus. The module is nice as it is. Just fix the problem with the name, clean up the files a bit with comments and such as Wilco says, reformat the queries, better parameter descriptions and you're set.

kdevine
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 200
Joined: Thu Mar 02, 2006 8:38 pm
Location: Baltimore, MD

Re: 010 - Create a Joomla! 1.5 module listing all of the items in a given catego

Postby kdevine » Sat Dec 01, 2007 6:35 pm

The module class suffix shows up fine in properties for me, although I had to fix the code for it to be used. It's even in the XML, which I adapted from mod_latestnews.


Yes, moduleclass_sfx worked in my tests.

User avatar
fealebenpae
Joomla! Intern
Joomla! Intern
Posts: 54
Joined: Fri Nov 30, 2007 8:33 pm
Location: Vidin, Bulgaria

Re: 010 - Create a Joomla! 1.5 module listing all of the items in a given catego

Postby fealebenpae » Sat Dec 01, 2007 9:16 pm

I think I'm pretty much done with the basic stuff. Everything's working as I want it to. Based on your suggestions I let the site admin decide what the link layout will be and added an option to display the description and number of articles for each section and category. I left the Category names be links as having a separate Read More link would be cumbersome, now that there is only one type of link at any time.

I moved the release on Joomlacode to stable and I uploaded the package to the Extensions Directory. Let's see what the general public has to say.

Thanks for your help, guys :)
And it came to pass that in that time the Great God Om spake unto Brutha, the Chosen One: "Psst!"


User avatar
mcsmom
Joomla! Exemplar
Joomla! Exemplar
Posts: 7985
Joined: Thu Aug 18, 2005 8:43 pm
Location: New York
Contact:

Re: 010 - Create a Joomla! 1.5 module listing all of the items in a given catego

Postby mcsmom » Sun Dec 02, 2007 12:05 pm

Yavor,

One suggestion would be to use the pop up to select the section rather than asking the user to supply the number. You should be able to find how to do that in latestnews.

Other than that, worked like a charm.
So we must fix our vision not merely on the negative expulsion of war, but upon the positive affirmation of peace. MLK 1964.
http://officialjoomlabook.com Get it at http://www.joomla.org/joomla-press-official-books.html Buy a book, support Joomla!.

User avatar
fealebenpae
Joomla! Intern
Joomla! Intern
Posts: 54
Joined: Fri Nov 30, 2007 8:33 pm
Location: Vidin, Bulgaria

Re: 010 - Create a Joomla! 1.5 module listing all of the items in a given catego

Postby fealebenpae » Sun Dec 02, 2007 1:02 pm

@mcsmom,

Which version of latestnews has the pop up option? I'm using the October 5th Nightly and all I have is a plain text field to enter the ids. I tried changing the param type to section, but that only allows me to select one section at a time. I checked the SVN repo for mod_latestnews and the xml is the same as the one I have. Where exactly can I find a pop up example?
And it came to pass that in that time the Great God Om spake unto Brutha, the Chosen One: "Psst!"

User avatar
mcsmom
Joomla! Exemplar
Joomla! Exemplar
Posts: 7985
Joined: Thu Aug 18, 2005 8:43 pm
Location: New York
Contact:

Re: 010 - Create a Joomla! 1.5 module listing all of the items in a given catego

Postby mcsmom » Sun Dec 02, 2007 1:35 pm

Oh, you're right. I was thinking of the pop up that is used  when you link to articles. I do think you could use that but it would really put your module ahead of the core modules!  I would be lovely not to have to get the numbers manually though.
So we must fix our vision not merely on the negative expulsion of war, but upon the positive affirmation of peace. MLK 1964.
http://officialjoomlabook.com Get it at http://www.joomla.org/joomla-press-official-books.html Buy a book, support Joomla!.

User avatar
fealebenpae
Joomla! Intern
Joomla! Intern
Posts: 54
Joined: Fri Nov 30, 2007 8:33 pm
Location: Vidin, Bulgaria

Re: 010 - Create a Joomla! 1.5 module listing all of the items in a given catego

Postby fealebenpae » Sun Dec 02, 2007 1:55 pm

Well, I can probably extend JElement to reach the desired effect, but the changes will have to be included in the core files, but other modules will be able to benefit from it, which is a plus. I'll post a patch when I'm done.

EDIT: I managed to use a multiple selection box for the Sections, but there's a snag. Aside from having to add another JElement, I had to write a small hack for admin/com_modules' controller in order to have it parse the array data correctly. I'm attaching a package with the new module package, as well as the new Sectionlist JElement.

Here's the hack for com_modules' controller:

$params = array();
foreach($post['params'] as $param => $v) {
if(is_array($v)) {
$v = implode(',', $v);
}
$params[$param] = $v;
}
$post['params'] = $params;


It should go right after $post = JRequest::get( 'post' ); which is around line 260 for me.

If it's ok and not an overkill, I can submit a patch for this on the developer board.
You do not have the required permissions to view the files attached to this post.
Last edited by fealebenpae on Sun Dec 02, 2007 5:10 pm, edited 1 time in total.
And it came to pass that in that time the Great God Om spake unto Brutha, the Chosen One: "Psst!"

User avatar
fealebenpae
Joomla! Intern
Joomla! Intern
Posts: 54
Joined: Fri Nov 30, 2007 8:33 pm
Location: Vidin, Bulgaria

Re: 010 - Create a Joomla! 1.5 module listing all of the items in a given catego

Postby fealebenpae » Mon Dec 03, 2007 8:46 pm

Where can I get information about internationalization and localization? I understand I have to go through JText and JLanguage to handle the translations, but I can't figure out how to load the language ini file or at least somehow indicate it in the xml file, as most of the strings I'll be translation are in the xml file.
And it came to pass that in that time the Great God Om spake unto Brutha, the Chosen One: "Psst!"

AmyStephen
Joomla! Champion
Joomla! Champion
Posts: 7056
Joined: Wed Nov 22, 2006 3:35 pm
Location: Nebraska
Contact:

Re: 010 - Create a Joomla! 1.5 module listing all of the items in a given catego

Postby AmyStephen » Tue Dec 04, 2007 5:05 am

1. Add this section to your mod_ghop_categories.xml file.

language/en-GB/en-GB.mod_ghop_categories.ini


2. Markup your XML for parameters. For example, look at the XML file for the core modules. You will see string literals like this example from mod_breadcrumbs:


3. Create your Language ini file: Look in the language/en-GB/en-GB.mod_breadcrumbs.ini file (which you will create as en-GB.mod_ghop_categories.ini)

PARAMSHOWHOME=Show/Hide the Home element in the Pathway


See if that makes sense. Already, you have accomplished remarkable achievements. This will be a popular module. You created a hack to the core - and plan to deliver it as a patch. Now, you are preparing for an International implementation. You are doing great work.

Hope you are having fun!
Amy :)

User avatar
fealebenpae
Joomla! Intern
Joomla! Intern
Posts: 54
Joined: Fri Nov 30, 2007 8:33 pm
Location: Vidin, Bulgaria

Re: 010 - Create a Joomla! 1.5 module listing all of the items in a given catego

Postby fealebenpae » Tue Dec 04, 2007 7:38 pm

I implemented internationalization and I added language files for English and Bulgarian. The final release is on joomlacode. Also, I posted the patch I devised for the Section and Category JElements on the dev board

I can't think of anything else to add or do, so I'm calling for a final review.

@AmyStephen

Yeah, I'm having lots of fun working with the new framework. It's really powerful - I feel constrained working with Sunfire, but Khepri gives me a lot of flexibility and opportunities to do the things I want in a lot less code ^^
And it came to pass that in that time the Great God Om spake unto Brutha, the Chosen One: "Psst!"

User avatar
ianmac
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4785
Joined: Sat Sep 24, 2005 11:01 pm
Location: Toronto, Canada

Re: 010 - Create a Joomla! 1.5 module listing all of the items in a given catego

Postby ianmac » Wed Dec 05, 2007 11:10 pm

If the Element is specific to your module, it should not be part of the core, rather it should be installed with the module and the folder specified using the addParamPath attribute in your XML.  If you need more info on this, let me know.  I thought I had posted about this, but I can't find it right now.

Ian

User avatar
fealebenpae
Joomla! Intern
Joomla! Intern
Posts: 54
Joined: Fri Nov 30, 2007 8:33 pm
Location: Vidin, Bulgaria

Re: 010 - Create a Joomla! 1.5 module listing all of the items in a given catego

Postby fealebenpae » Wed Dec 05, 2007 11:33 pm

I ended up modifying the original JElement, rather than create a carbon copy of the old one and modify two lines in it. But in order for the JElement to work properly, there is a patch that needs to be applied to controller.php in administrator/com_modules, otherwise the controller does not handle the post data from the

Return to “Google's Highly Open Participation Contest”

Who is online

Users browsing this forum: No registered users and 1 guest