Keyword

Display Extra Fields in 2nd & 3rd column of table

  • Justin Place
  • Justin Place's Avatar Topic Author
  • Offline
  • Senior Member
More
11 years 4 months ago #115514 by Justin Place
Hi there, I have managed to insert the Items list in my html Table here:
www.borderlearning.justrite.co.za/index.php/component/k2/itemlist/category/9-bnb

I have also linked each item to its own extra field for its [Contact Number] & [Further Details]

How do i Display each items Contact number in the Contact number Column?

I have tried to insert the code in category_item.php but it still does not want to work

my Extra field alias for the 2 are:

Contact Number - contract
Further Details - details

I am really frustrated on trying to insert the data correctly,

If anyone could please help i would greatly appreciate it!

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 #115515 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: Display Extra Fields in 2nd & 3rd column of table
Hello Justin,

This requires some coding, and altering completely your K2 template.
I think the best solution would be hiring a developer if you are not comfortable with PHP/HTML code.

If you choose to do it yourself I can guide you.

Currently you have the entire loop in one <td> you need to have your <th> elemtents static in your category.php and inside the foreach loop produce three <td> elements, one for the title and one for each extrafield.

something like this quick draft

foreach()
<tr>
<td>Title</td>
<td>Field 1</td>
<td>Field2</td>
</tr>
endforeach()

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 #115516 by Justin Place
Hi,

Thanks, I kinda don't have a ton of php/html experience
but if the steps are there i can follow them

Is this done all in the Category.php file?

In the category.php file i have added this:

<table align="center">
<tr>
<th>Listing</th>

<th>Contact Number</th>

<th>Further Details</th>
</tr>
<tr>
<td>
<div class="itemList">
... (the whole item list section)
</td>
</tr>
</table>

I actually have seen that php foreach code before

I have never actually implemented a a foreach loop before.

I wish i could pay a developer but can't at the moment..

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 #115517 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: Display Extra Fields in 2nd & 3rd column of table
The foreach statement is in your category.php One for each item group.

You have to only use one ( eg. leading ).

Look in your category.php for the leading group and insert your table and th's there.
Then apply the three td's inside your category_item.php.

Hint. make sure inside foreach statement in your category.php that there is no markup loaded, only the category_item template part.

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 - 11 years 4 months ago #115518 by Justin Place
Okay i just want to see if I'm understanding correctly

I insert like so:
<div id="itemListLeading">
<?php foreach($this->leading as $key=>$item): ?>
...
<table>
<tr>
<th>Listing</th>
<th>Contact Number</th>
<th>Further Details</th>
</tr>
...
<?php endforeach; ?>
</table>

In the category_item.php file where do i insert the td's because one column will be the item list and the other two columns will be the extra field data

Edit: I'm not sure If im on the right track: www.borderlearning.justrite.co.za/index.php/component/k2/itemlist/category/9-bnb

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 #115519 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: Display Extra Fields in 2nd & 3rd column of table
On the contrary you should to the exact oppposite.

I insert like so:
<div id="itemListLeading">
<table>
<tr>
<th>Listing</th>
<th>Contact Number</th>
<th>Further Details</th>
</tr>
<?php foreach($this->leading as $key=>$item): // the following edits are now in category_item ?>
<tr>
<td><td><td>
</tr>
<?php endforeach; // from this point and bellow category.php again ?>
</table>

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 - 11 years 4 months ago #115520 by Justin Place
okay, thank you for clearing things for me,

I have added the code you recommended, to the category.php and the tds in the category_item.php

I have managed to get the extra field [contact number] to display, BUT its displayed underneath the items list.

Any suggestions to get the extra fields to display in its own column?

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 #115521 by Justin Place
Hi Krikor,

I have changed the table format, to Css Listing, I have got my 2nd column displayed by adding in my Extra field [Contact number] in:

<div class="extrafield-colcontact">
<ul>
<li><?php echo $this->item->extraFields->contact->value ;?></li>
</ul>
</div>

I tried adding my THIRD column like so:

</div>
<div class="extrafield-coldetails">
<ul>
<li><?php echo $this->item->extraFields->details->value ;?></li>
</ul>
</div>

Iv added some data for the extra field, but the column data will not display.
link:
www.borderlearning.justrite.co.za/index.php/component/k2/itemlist/category/9-bnb

Any code that I'm missing?

Thanks

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 #115522 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: Display Extra Fields in 2nd & 3rd column of table
Hello Justin,

The codec seems correct. You should recheck for any typos in the extrafield alias
<?php if(isset($this->item->extraFields->EXTRAFIELDALIASHERE->value)): ?>
     <?php echo $this->item->extraFields->EXTRAFIELDALIASHERE->name; ?>
       <?php echo $this->item->extraFields->EXTRAFIELDALIASHERE->value; ?>
<?php endif; ?>

Try this as well, If id does not render then you probably have a typo.

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 - 11 years 4 months ago #115523 by Justin Place
hi,

I've managed to get it to display properly.

My Third column extra field is "View profile"

How can i remove the item's "user profile" link and have it for my extra field?

Thanks

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


Powered by Kunena Forum