Joomla! Hack: How to Display a Page of all K2 Users, Groups and Blogs
It is always a joy discovering new things when building Joomla! web sites
Editor’s Note: Stay tuned for an update on EasyBlog integration with Weever Apps soon!
Also A quick note that I hope to see you at the official 2012 CMS Expo this year. Robert Porter and I will be showcasing our mobile app maker for Joomla!, Weever Apps. Our session is called “Creating HTML5 Mobile Web Apps with Joomla!” and we hope to see you there!
K2 is a powerful extension for Joomla! that adds many of the “missing features” – visitor comments, navigation comments, navigation-by-keyword (tag), and so on – in the default platform.
One of my favorite parts of K2 is the extensible “authorship” system. Each registered “author” on the site can have an “author page” with their latest blog posts. Nifty!
Here’s an example from the K2 Demo.
K2 stops just short of being a multi-user multi-blog platform like JomSocial, however, because Joomla! does provide a method to show a list of authors (and links to their latest blog posts) on a single web site.
For example, I needed to add a page like the one below to LiteraryCulture.ca. After trying a few solutions inspired by ultimately unsuccessful hacks like this one, I found a zero-programming solution!
Creating a K2 User Page
Here’s what I did. Repeat this process to create a user-blog layout for specific groups of your site contributors:
Step One: Create Your K2 Groups
Navigate to “Components” –> “K2” –> “User Groups.” Modify or create new groups to match your needs. For example, I created three groups:
Then configure each group to have different levels of access for publishing to different blog categories on the site. It’s really up to you how far to go with this, but I recommend keeping it simple and smart. At minimum, every group needs to be able to post items, edit their own items, and edit from the “front end.”
Step Two: Use the “K2 users” Module.
K2 installs with a default “user module” that can show a list of author-page links. Open this module and manually set the position as “studentarticle” (or whatever term you prefer).
Set the module to fetch users “by K2 user group” and select any user group you wish (“authors,” for example).
Change the rest of the module parameters as you wish. I recommend showing the “avatar image,” the “user description,” and enabling most other options as well.
Step Three: The Power of LoadPosition
Joomla! has a powerful, but underused, ability to show a “module” inside an article known as “loadposition”
Create a new K2 blog category named “Members.” Create a K2 item (or Joomla! article) named “Students.” Then in the article text add the following:
The article will now display a list of your users, sorted according to the settings in the “K2 users” module. Nice!
Step Four:Link to this Page
This one’s easy. Open your menu manager, and add a K2 single-article layout to your menu. Follow the link on your desktop site. You should now see a single page with a somewhat-ugly list of users. Each user’s avatar and name will link back to their profile and personal blog.
I recommend adding a page-suffix to the menu item when editing, like ” myuserpagecss,” but you don’t have to do this at all.
Step Five: Make it CSS Snappy!
By default, you’ll probably see some alternating yellow and white list-style display – not exactly beautiful for page, but it wasn’t meant for that after all.
Fortunately, you can change all of these design elements to look just like a normal blog layout. Identify the CSS rules with something like Firebug or Web Inspector and then update your template’s CSS file to match.
Using a menu “page suffix” makes this a little easier, but it’s not required.
Optional Step Six: Make it Awesome
That’s it! Copy the “K2 user” module as many times as you like and add new loadpositions, articles and menu items for as many user-groups as you would like to feature.
All in all, this makes K2 a pretty robust social-blogging platform! Since K2′s user profile fields are extensible by default, you could take this approach a step further and also add info like a Twitter user name, site address, or whatever you like to every profile page.
For example, I created a blog-layout of my user-group-list-pages (wordy enough?) to show each group with a list of members on each page. That’s only day one, so the sky’s the limit!
I also have to mention the Weever Apps inveted Joomla! mobile-map-making tool “GeoTagger” here. I’d love to see a simple and slim community site built around desktop and mobile, GPS and app-enabled mobile maps.
Authors would have the option of adding map marker(s) with every post – all controlled by Joomla!’s native publishing system. K2 comments would allow community members to comment, rate, review, and discuss each post, and even locations, this way!
Summary: Necessity, Invention, Repeat
As the old idiom goes, necessity is the mother of invention, and that is one of the best things about Joomla!. When the necessity presents itself, the tools are most likely there if you can apply them creatively enough. If we can create a community platform with a simple hack, just imagine what else is possible. Joomla! rocks!
Please note: This hack/method has only been tested with Joomla 1.5 and K2. While it should work with other sites, you’ll need to verify that on a per-site and per-version basis.