Keyword

Directory Listing K2 items in a table w/ columns

  • Justin Place
  • Justin Place's Avatar Topic Author
  • Offline
  • Senior Member
More
11 years 4 months ago - 11 years 4 months ago #114217 by Justin Place
Hi, i have a directory website

I want to display all the listings (K2 items) on a simple table with some columns:

Column 1: Listing name
Column 2: Contact Number
Column 3: Further details - "View profile" link

Quite similar to this table:
imageshack.us/a/img541/8485/bedandbreakfastspage.png

Is this possible with a K2 extension, preferably non-commercial, since iv already purchased modules for K2.

Kind regards
Justin

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
11 years 4 months ago #114218 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: Directory Listing K2 items in a table w/ columns
Hello Justin,

It is possible if you override category.php and category_item.php and you are familiar with simple coding.

Inside category.php outside the items loop (foreach) you have to open and close your <table> element.
Now open category_item.php. Insert a <tr> element on top and close it at the end.

Show your content inside <td> elements. Use one td for the title and one for each of your extrafields. For more information on rendering extrafields you should read this post .
getk2.org/community/New-to-K2-Ask-here-first/171284-Where-to-edit-K2-after-Item-Fields#171348

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • Justin Place
  • Justin Place's Avatar Topic Author
  • Offline
  • Senior Member
More
11 years 4 months ago #114219 by Justin Place
Replied by Justin Place on topic Re: Directory Listing K2 items in a table w/ columns
Hi krikor,

Thanks for the reply.
I'm not sure where category.php & category_item.php files would be?

I am relatively okay with php in some aspects, but could you give me an example please of what i must edit to get it correct?
sorry if i am being a pain?

maybe it will help others who don't know much to guide them in the right direction.

Kind regards,
Justin

Please Log in or Create an account to join the conversation.

  • Mohamed Abdelaziz
  • Mohamed Abdelaziz's Avatar
  • Offline
  • Platinum Member
  • Joomla Developer
More
11 years 4 months ago #114220 by Mohamed Abdelaziz
Replied by Mohamed Abdelaziz on topic Re: Directory Listing K2 items in a table w/ columns
Hello Justin,

category.php and category_item.php can be found inside components/com_k2/templates/default folder.

But you need to read more about templates overrides before starting this modifications, you can read this document for more details: getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates

Multiple Extra Fields Groups for K2
AutoMeta for K2
Chained Fields for K2
More K2 Extensions In My Extensions Store

Please Log in or Create an account to join the conversation.

  • Justin Place
  • Justin Place's Avatar Topic Author
  • Offline
  • Senior Member
More
11 years 4 months ago - 11 years 4 months ago #114221 by Justin Place
Replied by Justin Place on topic Re: Directory Listing K2 items in a table w/ columns
Thanks Mohamed!

But you need to read more about templates overrides before starting this modifications, you can read this document for more details: getk2.org/documentation/tutorials/174-te...pts-of-sub-templates


Thanks!! I read that and followed the instructions there.
I have made a duplicate of the "default" folder in my JoomlaTemplate/html/com_k2
called "Listing page" which will be the template for all my listings.
Pretty cool.

I found this link very helpful! maybe it will help others : www.modernmagic.com/blog/joomla-technical-support/k2-table-like-list-in-category-view.html

Ill give it a shot and see how it goes..

Kind regards

Please Log in or Create an account to join the conversation.

  • Justin Place
  • Justin Place's Avatar Topic Author
  • Offline
  • Senior Member
More
11 years 4 months ago - 11 years 4 months ago #114222 by Justin Place
Replied by Justin Place on topic Re: Directory Listing K2 items in a table w/ columns
Hi,

I don't think I am inserting the <table> code in the right place, because its not showing after I have assigned the category template to my custom one:
<!-- Item list -->
        <table>
        <div class="itemList">
                <?php if(isset($this->leading) && count($this->leading)): ?>
                <!-- Leading items -->
                
                <div id="itemListLeading">
                        <?php foreach($this->leading as $key=>$item): ?>

                        <?php
                        // Define a CSS class for the last container on each row
                        if( (($key+1)%($this->params->get('num_leading_columns'))==0) || count($this->leading)<$this->params->get('num_leading_columns') )
                                $lastContainer= ' itemContainerLast';
                        else
                                $lastContainer='';
                        ?>
                        
                        <div class="itemContainer<?php echo $lastContainer; ?>"<?php echo (count($this->leading)==1) ? '' : ' style="width:'.number_format(100/$this->params->get('num_leading_columns'), 1).'%;"'; ?>>
                                <?php
                                        // Load category_item.php by default
                                        $this->item=$item;
                                        echo $this->loadTemplate('item');
                                ?>
                        </div>
                        <?php if(($key+1)%($this->params->get('num_leading_columns'))==0): ?>
                        <div class="clr"></div>
                        <?php endif; ?>
                        <?php endforeach; ?>
                        
                        <div class="clr"></div>
                </div>
                <table>

And <tr> for the category_item.php is inserted at the top and bottom of the item-layout?

I don't think I'm understanding the template override that well :( :blush:

kind regards

Justin

Please Log in or Create an account to join the conversation.

  • Mohamed Abdelaziz
  • Mohamed Abdelaziz's Avatar
  • Offline
  • Platinum Member
  • Joomla Developer
More
11 years 4 months ago #114223 by Mohamed Abdelaziz
Replied by Mohamed Abdelaziz on topic Re: Directory Listing K2 items in a table w/ columns
Hello Justin,

I think you missed a folder in the template override structure, your templates should be under: JoomlaTemplate/html/com_k2/templates

Try to add the templates folder, I think it will work.

Multiple Extra Fields Groups for K2
AutoMeta for K2
Chained Fields for K2
More K2 Extensions In My Extensions Store

Please Log in or Create an account to join the conversation.

  • Justin Place
  • Justin Place's Avatar Topic Author
  • Offline
  • Senior Member
More
11 years 4 months ago #114224 by Justin Place
Replied by Justin Place on topic Re: Directory Listing K2 items in a table w/ columns
Hi Mohamed,

Im quite sure the folder is like you said MyTemplate/html/com_k2/Templates/Listing Page

I assigned the category item layout to "Listing Page"
but theres no layout that's changed.
What do you think I'm doing wrong or missing to add?

Please Log in or Create an account to join the conversation.

  • Mohamed Abdelaziz
  • Mohamed Abdelaziz's Avatar
  • Offline
  • Platinum Member
  • Joomla Developer
More
11 years 4 months ago #114225 by Mohamed Abdelaziz
Replied by Mohamed Abdelaziz on topic Re: Directory Listing K2 items in a table w/ columns
Hi Justin,

Do you enter folder names as you write in this post?
I mean "Listing Page" with space between words?
Try to not use space, and also rename the folder Templates to templates, if you used capital letter 'T'

Let me if this solved the problem.

Multiple Extra Fields Groups for K2
AutoMeta for K2
Chained Fields for K2
More K2 Extensions In My Extensions Store

Please Log in or Create an account to join the conversation.

  • Justin Place
  • Justin Place's Avatar Topic Author
  • Offline
  • Senior Member
More
11 years 4 months ago - 11 years 4 months ago #114226 by Justin Place
Replied by Justin Place on topic Re: Directory Listing K2 items in a table w/ columns
changed in to "listingpages" and assigned it to the subcategory

still no luck.

here is one of the listing pages - www.borderlearning.justrite.co.za/index.php/component/k2/itemlist/category/9-bnb

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum