Keyword

Display extra fields in content item page? *SOLVED

  • Andrew Pearce
  • Andrew Pearce's Avatar Topic Author
  • Offline
  • New Member
More
10 years 1 month ago - 10 years 3 weeks ago #131160 by Andrew Pearce
Hi
Is there any way to display the Extra fields half way into a k2 article/item? ie not at the top or bottom. I know I can muck around with item.php but I want the field to display in the actual article. I thought about putting a module position in the page and then calling the extra fields in there but have no idea how to do it.
Any ideas?
Thanks
Andrew

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 1 month ago #131161 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: Display extra fields in content item page?
Hello Andrew,

No need to place a module.
You can directly render extrafields,

This post will help you:
getk2.org/community/English-K2-Community/194709-SOLVED-Specific-Extra-Field-Data-repeats-info

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

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

  • Andrew Pearce
  • Andrew Pearce's Avatar Topic Author
  • Offline
  • New Member
More
10 years 1 month ago #131162 by Andrew Pearce
Replied by Andrew Pearce on topic Re: Display extra fields in content item page?
Hi Krikor
Thanks for your help, but I'm afraid I don't get it. That post says you need a k2 content module, but that chooses which k2 item to take the extra fields from so I'd have to set up one for every page wouldn't I? There will be about 350 pages, once I've sorted this out.
You also said I don't need a module to do it so I tried pasting:
<?php
if (!isset($item->extraFields))
{
$item->extraFields = new stdClass;
}
foreach ($item->extra_fields as $extraField)
{
$tmpAlias = $extraField->alias;
$item->extraFields->$tmpAlias = $extraField;
}
?>

<div class="moduleItemExtraFields"><span class="moduleItemExtraFieldsValue"><?php echo $item->extraFields->EXTRAFIELD_ALIAS->value; ?></span>

..into the K2 item but it just shows code. Here's my page web-53.mydns.net.nz/latitudehomes.co.nz/index.php/our-designs/single-story-homes/single-story-2-bedroom/item/48-nz-80-hunter
(it has a username and password on it just to stop google, which is latitudetemp1 for both)

You can see the extra fields at the bottom. Those are the normal K2 ones. I want them up under the heading, before the main copy. I had to make that page up with tables so it would be easier for people to edit, So I have the heading as part of the content area.

Thanks for any help.

Andrew

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 1 month ago #131163 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: Display extra fields in content item page?
If you want all extrafields to render, then you have to move the extrafield's loop.
<?php if($this->item->params->get('itemExtraFields') && count($this->item->extra_fields)): ?>
	  <!-- Item extra fields -->
	  <div class="itemExtraFields">
	  	<h3><?php echo JText::_('K2_ADDITIONAL_INFO'); ?></h3>
	  	<ul>
			<?php foreach ($this->item->extra_fields as $key=>$extraField): ?>
			<?php if($extraField->value != ''): ?>
			<li class="<?php echo ($key%2) ? "odd" : "even"; ?> type<?php echo ucfirst($extraField->type); ?> group<?php echo $extraField->group; ?>">
				<?php if($extraField->type == 'header'): ?>
				<h4 class="itemExtraFieldsHeader"><?php echo $extraField->name; ?></h4>
				<?php else: ?>
				<span class="itemExtraFieldsLabel"><?php echo $extraField->name; ?>:</span>
				<span class="itemExtraFieldsValue"><?php echo $extraField->value; ?></span>
				<?php endif; ?>
			</li>
			<?php endif; ?>
			<?php endforeach; ?>
			</ul>
	    <div class="clr"></div>
	  </div>
	  <?php endif; ?>

If you want to render some extrafields on the top and some on the bottom, then you should follow the direction of the post.

I am also assuming that you are using overrides, if not, please start using them.
This post will help you: getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates

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

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

  • Andrew Pearce
  • Andrew Pearce's Avatar Topic Author
  • Offline
  • New Member
More
10 years 1 month ago #131164 by Andrew Pearce
Replied by Andrew Pearce on topic Re: Display extra fields in content item page?
Thanks Krikor
I get that about moving to top or bottom using item.php and overrides, but I want to move it into the middle of a content item. I sort of have it how I want it changing the css of .itemExtraFields at web-53.mydns.net.nz/latitudehomes.co.nz/index.php/our-designs/single-story-homes/single-story-2-bedroom/item/48-nz-80-hunter
(it has a username and password on it just to stop google, which is latitudetemp1 for both) but I doubt that is the best way of doing it because I think it would look different on other devices. Plus I don't know enough about it to get the copy to drop down underneath apart from putting a spacer gif underneath to push the copy down. (It's has a temp yellow background just so I can see what's happening) So is there a better way of doing that?
Thanks for your help again.
Andrew

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

More
10 years 1 month ago #131165 by Lefteris
Replied by Lefteris on topic Re: Display extra fields in content item page?
@Andrew Pearce

Hi. I read all the conversation and still cannot get what exactly you are trying to achieve. You cannot put extra fields inside introtext of fulltext. You can put it before of after introtext for example.

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

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

  • Andrew Pearce
  • Andrew Pearce's Avatar Topic Author
  • Offline
  • New Member
More
10 years 4 weeks ago #131166 by Andrew Pearce
Replied by Andrew Pearce on topic Re: Display extra fields in content item page?
Hi Lefteris. Yes, that's what I want, extra fields in fulltext. I think I've found a way to do it. I'll load a module position in the content, then use K2 Split content. www.marathonsoftware.com.au Haven't done it yet, got tied up with other projects but that's what I'll do in the next couple of days.
Thanks for your reply.
Andrew

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 4 weeks ago #131167 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: Display extra fields in content item page?
I am really curious to see the end result.
Once you are done please post an example Andrew.

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

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

  • Andrew Pearce
  • Andrew Pearce's Avatar Topic Author
  • Offline
  • New Member
More
10 years 3 weeks ago #131168 by Andrew Pearce
Replied by Andrew Pearce on topic Re: Display extra fields in content item page?
Hi Krikor. You can see the mostly finished result at web-53.mydns.net.nz/latitudehomes.co.nz/index.php/our-designs/single-story-homes/single-story-2-bedroom/item/48-nz-80-hunter
(it has a username and password on it just to stop google, which is latitudetemp1 for both) and I've only set up that one page at the mo with extra filters.
So the Heading, "NZ80 Hunter" is actually in the content item to get the pic o the right to align. I turned off the Show Title. Then the Extra fields down to Full Build, then more content.

For anyone else wanting to do the same thing, I bought K2 Split Content (only $20) from www.marathonsoftware.com.au/products/commercial-products/k2-split-content Set that up so it only shows K2 Extra fields (you can choose any other K2 options though) and made it show on all pages in a custom module position called "donotdelete" (So the fullas editing don't delete it)
Then in my content I added the module position, so just put {loadposition donotdelete} in there.
I wanted extra fields to show on the intro text, so in the category settings I had show fields on. Then I commented out the extra fields stuff in item.php (lines roughly 68 to 89} You're best to set up overrides so item.php should be in yourtemplate/html/com_k2/templates/templatename/item.php (you also choose the template name in category K2 settings.)
I couldn't get the template override to work for K2 Split content prob cause I'm a bit crap, but I copied the default template in modules, mod_k2_split _content/tmpl/Default/default.php (Change the template name in the module settings to whatever your new one is called) Then I changed lines 195 - 196 approx to this so I could add extra styles for each extra field instead of the text heading. It adds the extra fields name alias to the style

<span class="itemExtraFieldsLabel<?php echo $extraField->alias;?>"><?php echo $extraField->name;?></span>
<span class="itemExtraFieldsValue"><?php echo $extraField->value;?></span>

Then I can set styles for each one. So the bedrooms extra field has "bedrooms" as the alias so the style is

.itemExtraFieldsLabelbedrooms {
float: left;
width: 34px;
height: 30px;
background-image: url(../../../images/template_images/bedrooms-icon.png);
background-repeat: no-repeat;
background-position: right top;
text-indent: 100%;
white-space: nowrap;
overflow: hidden;

}

And that should be it. The reason I'm using extra fields like that is so that people editing (and there will be a few different ones) can easily choose how many bedrooms, bathrooms etc when editing, and I will use a search filter like K2 Filter as a search so the end user can find a house plan by choosing region, how many bathrooms, price range etc. Haven't set that up yet.
Thanks for everyones help, and Mark from Marathon was a great help too.
Now I just have to finish the other million pages.

Andrew

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 3 weeks ago #131169 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: Display extra fields in content item page?
Thank you Andrew.

This was really interesting. I haven't heard of that extension before.
I will keep it in mind so users can benefit as well.

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

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


Powered by Kunena Forum