032 - Create a section content view that combines a category list...

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
Kevin8020
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 102
Joined: Wed Feb 01, 2006 3:53 am
Location: USA
Contact:

032 - Create a section content view that combines a category list...

Post by Kevin8020 » Sat Dec 01, 2007 7:39 pm

Content layout in Joomla! 1.5 is controlled in important ways by the view
selected when a menu link is created. The Joomla! core includes a set of
content views, some of which are described as blog views and some are
generally described as list or table views.

For this task you will create a new section view that from a menu link
first presents a list of categories and then when the category names are
clicked, presents a blog view of the articles in the category.
I am a sophmore at a private High School in Denver, Colorado. I've enjoyed working on web coding projects all my life, and have enjoyed time working on the zOOm Media Gallery and old Joomla-SMF bridge. I'm just finishing up getting my Aptana IDE ready to get to work on this project. So far it seems fairly straight forward. It requires modifying the menu component (admin) in order to add the new view. Then the creation of a new view in com_content to display a table with the list of categories. Clicking the category would then link to the corresponding category (view=category).

The only thing I haven't been able to come up with yet is a name for the new section view.

Claimed: Dec 5 Due Jan 2

Google Task

[me=AmyStephen]Changed subject slightly for sorting all threads to match against Google resource  :)[/me]
Last edited by AmyStephen on Wed Dec 12, 2007 6:58 am, edited 1 time in total.

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

Re: 032 - Create a section content view that combines a category list...

Post by AmyStephen » Sun Dec 02, 2007 3:54 am

How about naming it "Yes, FINALLY, A Section-Category-Article View!"? ...just a thought!  ;)

Thanks for joining the contest - this will be a very popular extension. Feel free to ask for feedback from the community and for any help you require.

GHOP Contestants Please Read: Task Process Start to Finish for important updates on the contest.

See you around - have fun and good luck with the contest!
Amy :)

User avatar
Kevin8020
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 102
Joined: Wed Feb 01, 2006 3:53 am
Location: USA
Contact:

Re: 032 - Create a section content view that combines a category list...

Post by Kevin8020 » Mon Dec 03, 2007 4:23 am

Another brief question, how should I submit the final code? Should I just make sure i keep track of the changed files and post them when I'm done?
Last edited by Kevin8020 on Mon Dec 03, 2007 4:34 am, edited 1 time in total.

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

Re: 032 - Create a section content view that combines a category list...

Post by AmyStephen » Mon Dec 03, 2007 4:33 am

Make certain to read the link I made in my previous post. Also, I have server space you can use to FTP your work and link it, if you want. Just PM me. Or, you can use JoomlaCode.org for your program.

But, the process question is answered in that link.

Thanks!
Amy :)

User avatar
Kevin8020
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 102
Joined: Wed Feb 01, 2006 3:53 am
Location: USA
Contact:

Re: 032 - Create a section content view that combines a category list...

Post by Kevin8020 » Fri Dec 07, 2007 6:13 am

I think I've overlooked something... but I'm not sure. I pulled open the "section" view of com_content. Is this modification as simple as duplicating that view under a different name and instead of linking to a summary when clicking on the category name, it simply brings up that category's blog view??

If so, would it not just be easiest to add this as a sub-layout of section?

----

Continuing this, if a sub-layout of the section view is fine, I think I may be done. I have two questions first though before I change my icon over to an exclamation point:
1) Did I get this right? I want to make sure i didn't read to far (or not far enough) into the instructions?
2) Is an SVN patch an acceptable way to post my adjusted code for review before uploading to google? If so, I've attached one here.

NOTE: The included code isn't quite complete yet. I still need to remove some unused functions and change all the comments
You do not have the required permissions to view the files attached to this post.
Last edited by Kevin8020 on Fri Dec 07, 2007 1:42 pm, edited 1 time in total.

User avatar
Kevin8020
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 102
Joined: Wed Feb 01, 2006 3:53 am
Location: USA
Contact:

Re: 032 - Create a section content view that combines a category list...

Post by Kevin8020 » Sat Dec 08, 2007 9:53 pm

Again, I need some clarification here. The task states that this should be "A complete view folder that could be inserted into the com_content folder."

Would this not be easier to do as a layout for the section view? That is how I currently have it setup. I can switch over to the other method, though I think it would be rather superfluous.

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

Re: 032 - Create a section content view that combines a category list...

Post by AmyStephen » Sun Dec 09, 2007 6:47 am

I think you are right in your view versus layout discussion.

I've thought about this, but have not heard/seen a good answer about how these should get packaged. Your question is also my question and I suspect there is no good answer yet.

An SVN patch will not work as extension for sharing on the JED. So, at least create a ZIP file and some manual instructions on how to install at this point. Then, we can install and get some code review going.

I'll try to get some more experienced perspective on this.

Thanks!
Amy :)

User avatar
Kevin8020
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 102
Joined: Wed Feb 01, 2006 3:53 am
Location: USA
Contact:

Re: 032 - Create a section content view that combines a category list...

Post by Kevin8020 » Sun Dec 09, 2007 9:38 pm

Alright then. I've attached two things.

1) The svn.patch file
2) A zip archive with my changes. Simple extract that archive into your Joomla root to get the changed files.

CHANGES:
1) administrator/language/en-GB/en-GB.com_content.ini (UPDATED)
2) components/com_content/views/section/view.html.php (UPDATED)
2) components/com_content/views/section/tmpl/categoryblog.php (NEW)
2) components/com_content/views/section/tmpl/categoryblog.xml (NEW)
You do not have the required permissions to view the files attached to this post.

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

Re: 032 - Create a section content view that combines a category list...

Post by mcsmom » Tue Dec 11, 2007 9:32 pm

I think a zip file is fine. All you need to do to install a view is to unzip and put it in the right folder.

When it is ready, I would post it in the snippets area of joomlacode.
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!.

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

Re: 032 - Create a section content view that combines a category list...

Post by AmyStephen » Wed Dec 12, 2007 6:57 am

Kevin8020 -

Elin, Ian and I spent a bit of time on this one, tonight. We accept this as complete - please post it on the Google site and we will mark your task complete there, too.

Part of the reason we discussed it for so long is that it doesn't work correctly when SEF URLs are activated. Somehow, Joomla! is losing the layout parameter. We also don't know that this can easily be resolved and we don't want to hold you up if you want to get another task.

You did everything we asked of you. Your application works perfectly. You will not be able to resolve the issue we found. Ian will be talking with Louis Landry, as there is time, to see if there is an answer to this. If we find one, we'll post back into this forum and help you improve the code.

But, for now, we thank you for your contributions to our community and encourage you to get another task if you are interested. You have obvious skill and are to be encouraged with your work.

Task complete.
Amy :)

User avatar
Kevin8020
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 102
Joined: Wed Feb 01, 2006 3:53 am
Location: USA
Contact:

Re: 032 - Create a section content view that combines a category list...

Post by Kevin8020 » Wed Dec 12, 2007 7:51 am

Great! Do I need to move anything into JoomlaCode, or is this completed?

User avatar
Kevin8020
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 102
Joined: Wed Feb 01, 2006 3:53 am
Location: USA
Contact:

Re: 032 - Create a section content view that combines a category list...

Post by Kevin8020 » Wed Dec 12, 2007 8:10 am

Also, I don't know if this can count for extra credit or something, but I've attached a new version of the router.php in com_content that fixes the SEF problem completely.
You do not have the required permissions to view the files attached to this post.

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

Re: 032 - Create a section content view that combines a category list...

Post by AmyStephen » Wed Dec 12, 2007 1:58 pm

Kevin8020 wrote: Also, I don't know if this can count for extra credit or something, but I've attached a new version of the router.php in com_content that fixes the SEF problem completely.
lol! Um....yea, that would certainly count as extra credit to me! You carry on with your new task - and we'll get back to you on this.

You are blowing me away.  8)

Thanks!
Amy :)

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

Re: 032 - Create a section content view that combines a category list...

Post by mcsmom » Wed Dec 12, 2007 2:02 pm

Have you registered at joomacode? By all means please  do and put this in the snippets area. Just follow the instructions.
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!.

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

Re: 032 - Create a section content view that combines a category list...

Post by AmyStephen » Wed Dec 12, 2007 2:03 pm

Kevin -

One more comment. Would you please respond with the exact change you made the router? That might help expedite this process.

Had I not been so shocked (in a good way) initially, I would have asked in my previous post. 

Amy :)

Edit:
I see your code. We'll have to see why a core hack would be required for a new layout. Something still doesn't seem right. Don't know how long this will take, but we will be back with a response.  Thank you very much.

Code: Select all

	//Handle View and Identifier
	switch($item->query['view'])
	{
		case 'section' :
		{
			if($count == 1) {

				if(isset($item->query['layout']) && $item->query['layout'] == 'blog') {
					$vars['view'] = 'article';
				} else {
					$vars['view'] = 'category';
				}
			}

			if($count == 2) {
				$vars['view']  = 'article';
				$vars['catid'] = $segments[$count-2];
			}

			$vars['id']    = $segments[$count-1];

		} break;
Last edited by AmyStephen on Wed Dec 12, 2007 2:18 pm, edited 1 time in total.

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

Re: 032 - Create a section content view that combines a category list...

Post by mcsmom » Wed Dec 12, 2007 2:37 pm

One thing that would be cool would be to post over in the original thread about this

http://forum.joomla.org/index.php/topic,220696.0.html
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
Kevin8020
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 102
Joined: Wed Feb 01, 2006 3:53 am
Location: USA
Contact:

Re: 032 - Create a section content view that combines a category list...

Post by Kevin8020 » Thu Dec 13, 2007 12:38 am

Posted to JoomlaCode. I'll let you know if I have any ides to fix the SEF too... but I want to get that other module done too, so I'm going to work on that.

User avatar
danceswithlife
Joomla! Intern
Joomla! Intern
Posts: 82
Joined: Fri Mar 31, 2006 5:48 pm
Location: Dundalk Ontario Canada
Contact:

Re: 032 - Create a section content view that combines a category list...

Post by danceswithlife » Mon Dec 24, 2007 6:05 pm

Kevin8020,

It's really exciting to find this thread! Does/will it work with 1.0.13?
...we write documentation for extension developers.

User avatar
Kevin8020
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 102
Joined: Wed Feb 01, 2006 3:53 am
Location: USA
Contact:

Re: 032 - Create a section content view that combines a category list...

Post by Kevin8020 » Mon Dec 24, 2007 6:07 pm

At the moment, this feature is only compatible with Joomla 1.5. I might work on a 1.0.13 version too if I get some time here soon... but that's a completely different framework all together.

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

Re: 032 - Create a section content view that combines a category list...

Post by AmyStephen » Mon Dec 24, 2007 6:22 pm

Kevin did an excellent job on coding this extension. Honestly, it was a mistake to create this task. I believe we have gone outside of what is architecturally possible with Joomla!. Ian and Louis have discussed this and I do not believe we can generate good URLs. It's just a fundamental with Joomla!: menu items generate URLs. Stick to it, and you'll be okay. In this case, we don't have good URLs for the category blogs. I'm not certain we will recommend this extension be used, unless we can figure the URL issue out.

Again, the mistake was that of us - the GHOP judges - Kevin coded exactly what was called for.

Amy

User avatar
Kevin8020
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 102
Joined: Wed Feb 01, 2006 3:53 am
Location: USA
Contact:

Re: 032 - Create a section content view that combines a category list...

Post by Kevin8020 » Mon Dec 24, 2007 6:27 pm

Question then... If I went ahead and rewrote this as a completely separate view (that'd be like a 15 minute project at most) and named it something different, would that solve that problem?

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

Re: 032 - Create a section content view that combines a category list...

Post by AmyStephen » Mon Dec 24, 2007 6:43 pm

I do not believe so.

The category blog creates a menu item for SEF URLs (example assumes all 3 turned on):

http://Example.com/MenuItem.html

Linking to the articles (through the Read More or the Title) produces this:

http://Example.com/MenuItem/nn-category ... -name.html.

The overall router takes com_content and delivers program flow to that component. The com_content router then takes care of figuring out context - where the application is at.

There is no logic to accommodate a section - category - article link.

A separate component would work. A view or layout will not (to the best of my knowledge) since this goes outside of the definition of the com_content component.

Hope that makes sense (and is at least close to correct),
Amy :)

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

Re: 032 - Create a section content view that combines a category list...

Post by mcsmom » Mon Dec 24, 2007 7:03 pm

I think it MIGHT work as a view; my opinion from the beginning was that an entirely new view would be the best approach. But also, you could just create a component by copying com-content and changing its name, then moving things around a bit. I've done that before for something that was also out of scope for com_content but that used the content tables.  But for right now this is a great starting point to achieve what many users want. You have gotten way further than anyone else with this. I am definitely going to play with this. :) nice work!



I think the key is always FIRST get the non sef working, then get the sef working.
Last edited by mcsmom on Mon Dec 24, 2007 7:15 pm, edited 1 time in total.
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
Kevin8020
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 102
Joined: Wed Feb 01, 2006 3:53 am
Location: USA
Contact:

Re: 032 - Create a section content view that combines a category list...

Post by Kevin8020 » Mon Dec 24, 2007 7:26 pm

I'm still trying to relearn SEF on Joomla 1.5. I've worked with some older components on the 1.0 system with programs like openSEF, and I still think this is possible. Here's the thing: in the database, the menu items should each be associated with a layout. Thus, if the router file was to compare the menu name against the database to get the layout type, would that not work?

Brief addition: I have confirmed that with a bit of tweaking to router.php, the $layout variable from the menu item is successfully passing down through the levels. The problem comes when you get to a section-category table. The links there, without SEF, state that view=category&layout=blog. That layout=blog has NO way of being passed into the category component...

I completely separate view would fix that.
Last edited by Kevin8020 on Mon Dec 24, 2007 8:07 pm, edited 1 time in total.

ewel
Joomla! Guru
Joomla! Guru
Posts: 522
Joined: Mon Oct 01, 2007 11:35 am

Re: 032 - Create a section content view that combines a category list...

Post by ewel » Tue Dec 25, 2007 12:06 am

I have been keeping an eye on this thread out of interest because I find the logic of menu-based items counter-intuitive and impractical. I walked into this problem because of the category blog, and then in terms of where to publish modules. I have been working on a meta-module to publish other modules where I want (in particular a blog module on section and category pages !), but meanwhile I was hoping to find a solution that is independent of modules.

In Amy's last two posts I read that this is a fundamental matter and while I realise this is not the place to discuss future Joomla development I am curious to hear if there is any movement towards changing these fundamentals in the future?

At the same time, my thought (not hindered by any knowledge) when reading the last 5 posts was that if the issue is that menu items generate URLs would it not be in the way menus do that where it can be solved?

User avatar
danceswithlife
Joomla! Intern
Joomla! Intern
Posts: 82
Joined: Fri Mar 31, 2006 5:48 pm
Location: Dundalk Ontario Canada
Contact:

Re: 032 - Create a section content view that combines a category list...

Post by danceswithlife » Tue Dec 25, 2007 3:27 pm

Kevin8020,

Thanks for your reply! Waiting with baited breath!
...we write documentation for extension developers.

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

Re: 032 - Create a section content view that combines a category list...

Post by AmyStephen » Tue Dec 25, 2007 3:54 pm

Since it is Christmas Day, this will not be resolved today (or soon.) We encouraged Kevin to go on to the next task since we were not certain when - or if - we could make this work.

Ian responded that the problem of dropping the &layout=blog from the URL has been resolved in the core. (So, this is a non-issue, it sounds.)

The other issue that Ian and I had talked about was how the category parameters are determined. If I remember our conversation correctly, there are problems if the category has a menu item already (in such cases, Joomla! is simply using those menu item parameters.) I can't remember, but it seemed like there might have been a couple of issues.

When Ian has time, we can test some of this out and resolve this.

If you look at the feedback for the GHOP tasks, you will notice a couple of things. First of all, we are overwhelmed with the positive response of this contest and understaffed for the volume of tasks we are trying to handle. There are too many long waits and if we do this contest, again, we need three to five times the volunteers.

Secondly, and more importantly, you will see we are holding these pre-University students to very high standards. The last thing we want to happen is to have anything less than correct come out of GHOP and have people say that these brilliant and dedicated students are amateurs and not able to contribute in significant ways to Joomla!. Given the level of intelligence and abilities we have seen, nothing could be further than the truth. Many of these contestants, Kevin, included, belong right up there near the top. They are producing a high quality extension that we are willing to stand behind when we accept it as complete. We trust the work. We are confident of the result, given Joomla!'s architecture.

So, Kevin, I appreciate your patience with us. We have not forgotten this. We understand how valuable such an extension will be (as evidenced by the interest drawn to the thread), and we are here to help you be successful. As with anything else in Joomla!, it takes a community to make things happen and you are not alone in this.

Thank you for your contributions to our community,
Amy :)

User avatar
Kevin8020
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 102
Joined: Wed Feb 01, 2006 3:53 am
Location: USA
Contact:

Re: 032 - Create a section content view that combines a category list...

Post by Kevin8020 » Wed Dec 26, 2007 6:25 pm

I like Ian's fix, but unfortunately, it in itself is not SEF... I'm curious if there is a way to get this to work without being SEF. The problem is that my extension adds the layout=blog out of the blue. There is no way for the router to know that if the category view is called from within view=section&layout=categoryblog, then the category should be displayed as a blog.

So I think unless there can be another system there, I agree... this is the best solution for the time.

I also agree that a non-menu based SEF system would probably be good... but that's just my two cents... haha

EDIT: Oh, also, who would I contact to have this removed from snippets on JoomlaCode? I want to upload a version without the router changes now that that's been fixed.
Last edited by Kevin8020 on Wed Dec 26, 2007 6:27 pm, edited 1 time in total.

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

Re: 032 - Create a section content view that combines a category list...

Post by AmyStephen » Wed Dec 26, 2007 6:48 pm

Kevin8020 wrote: I like Ian's fix, but unfortunately, it in itself is not SEF... I'm curious if there is a way to get this to work without being SEF.
I believe it *does* work without SEF. In those cases, the parameters are being passed through, and not lost.
Kevin8020 wrote: The problem is that my extension adds the layout=blog out of the blue. There is no way for the router to know that if the category view is called from within view=section&layout=categoryblog, then the category should be displayed as a blog.
That's right.
Kevin8020 wrote: I also agree that a non-menu based SEF system would probably be good... but that's just my two cents... haha
I'm not certain anyone would disagree with you. But, this is a data model issue and, as such, is basically impossible to change until v 2.0
Kevin8020 wrote: EDIT: Oh, also, who would I contact to have this removed from snippets on JoomlaCode? I want to upload a version without the router changes now that that's been fixed.
Not certain - will have to ask around. How did you get it there to begin with?

User avatar
Kevin8020
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 102
Joined: Wed Feb 01, 2006 3:53 am
Location: USA
Contact:

Re: 032 - Create a section content view that combines a category list...

Post by Kevin8020 » Wed Dec 26, 2007 6:56 pm

AmyStephen wrote:
Kevin8020 wrote: I like Ian's fix, but unfortunately, it in itself is not SEF... I'm curious if there is a way to get this to work without being SEF.
I believe it *does* work without SEF. In those cases, the parameters are being passed through, and not lost.
Well yeah, it works with and without SEF... but with SEF on, you still get a ?layout=blog at the end of the URLs..
AmyStephen wrote:
Kevin8020 wrote: EDIT: Oh, also, who would I contact to have this removed from snippets on JoomlaCode? I want to upload a version without the router changes now that that's been fixed.
Not certain - will have to ask around. How did you get it there to begin with?
Hah. Um, I put it in there using the "add snippets" button at the bottom of all the pages in snippets...


Locked

Return to “Google's Highly Open Participation Contest”