- Posts: 15
COMMUNITY FORUM
- Forum
- K2 Community Forum
- English K2 Community
- [SOLVED] individual position of extra fields in item.php
[SOLVED] individual position of extra fields in item.php
- Klaus Fuchs
-
Topic Author
- Offline
- New Member
I am very new in K2 and i dont have much experience in php. I need to create a item.php with extra fields. The result should be like this:
blank.fuchs-net.de/index.php/sm.html
I founr the positions where the fields should be displayed.
But how to add?
I think I need to add this in a loop:
<div class="container">
<div class="col-md-3 fb"><?php echo '<p>extra field facebook icon to click</p>'; ?> </div>
<div class="col-md-3 fb"><?php echo '<p>extra field instagram icon to click</p>'; ?> </div>
<div class="col-md-3 fb"><?php echo '<p>extra field website icon to click</p>'; ?> </div>
</div>
but where:-(
somebody can help?
If its not too much I would also pay a small fee:-)
Regards Klaus
I also need to know how ta add css:see here--> www.joomlaworks.net/forum/k2-en/47985-how-to-add-css-class-to-a-extrafield
You will never hear these phrases from us:
We can't do that | I don't know what that is | I did everything on my own | That's too early | That's too late | It's too bad we couldn't work together | Let's catch up sometime | I'm sorry, I'm too busy | That was all my idea | If our competitors don't hav
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
github.com/kricore/Advanced-templating-with-K2/blob/master/_inc/cheatsheet.php#L168-L173
Just replace the alias and create your own markup (which you are halfway there).
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Klaus Fuchs
-
Topic Author
- Offline
- New Member
- Posts: 15
u mean it is the snippet from line 168 to 173?
As I dont know much abt. php I dont know where to add this in my item.php.
I have this extrafileds:
image_left
image_right
image_middle
goto_fb
goto_insta
goto_www
But where to add? I think I know that it has to be in a loop?!
Do u know somebody who could help me for this time, so that I understand more for the next projects? I f I see how, then I may know to solve it next tim. CSS should not be a problem, but php.. I am too old to learn some more:-)
Thanks
klaus
blank.fuchs-net.de/index.php/sm.html
You will never hear these phrases from us:
We can't do that | I don't know what that is | I did everything on my own | That's too early | That's too late | It's too bad we couldn't work together | Let's catch up sometime | I'm sorry, I'm too busy | That was all my idea | If our competitors don't hav
Please Log in or Create an account to join the conversation.
- Klaus Fuchs
-
Topic Author
- Offline
- New Member
- Posts: 15
I tried but I failed:-(
I add
<?php if( isset( $this->item->extraFields->goto_fb->value ) && ( $this->item->extraFields->goto_fb->value !== '') )
{ $this->item->extraFields->goto_fb->name;
$this->item->extraFields->goto_fb->value;
}
<?php endif; ?>
Where goto_fb is my extra field alias.
I placed this snippet in my item.php, but I always get this error:
SYNTAX ERROR, UNEXPECTED '<', EXPECTING END OF FILE
The page you are looking for was moved, removed, renamed or might never existed.
I understand that there is a syntax error but as mentioned before i do not have any php knowledge - just that I c an read the code:-)
Someone pls. could give me a hint?!
Thank you all for reading and helping
Klaus
You will never hear these phrases from us:
We can't do that | I don't know what that is | I did everything on my own | That's too early | That's too late | It's too bad we couldn't work together | Let's catch up sometime | I'm sorry, I'm too busy | That was all my idea | If our competitors don't hav
Please Log in or Create an account to join the conversation.
- Klaus Fuchs
-
Topic Author
- Offline
- New Member
- Posts: 15
I tried hard to understand:-)
I add this code
- the first container with the three extrafields:
it does not display my extra_Fields with the alias you can see here:
Below the container I did a dump of all extra_fields, and all is ok = display all my extra fields.
U can check here: blank.fuchs-net.de/index.php/sm.html
<div class="container">
<div class="col-md-4 image">
<?php if( isset( $this->item->extra_fields->image_left ) && ( $this->item->extra_fields->image_left->value !== '') )
{ $this->item->extra_fields->image_left->name;
$this->item->extra_fields->image_left->value;}?>
</div>
<div class="col-md-4 image">
<?php if( isset( $this->item->extra_fields->image_left ) && ( $this->item->extra_fields->image_left->value !== '') )
{ $this->item->extra_fields->image_left->name;
$this->item->extra_fields->image_left->value;}?>
</div>
<div class="col-md-4 image">
<?php if( isset( $this->item->extra_fields->image_left ) && ( $this->item->extra_fields->image_left->value !== '') )
{ $this->item->extra_fields->image_left->name;
$this->item->extra_fields->image_left->value;}?>
</div>
</div>
<!-- finish three images in a container -->
<!-- dump of all extra_fields-->
<?php var_dump($this->item->extra_fields); ?>
<!-- finish dump of all extra_fields-->
Help needed!
thanks
klaus
You will never hear these phrases from us:
We can't do that | I don't know what that is | I did everything on my own | That's too early | That's too late | It's too bad we couldn't work together | Let's catch up sometime | I'm sorry, I'm too busy | That was all my idea | If our competitors don't hav
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
<div class="col-md-4 image">
<?php if( isset( $this->item->extra_fields->image_left ) && ( $this->item->extra_fields->image_left->value !== '') )
{
echo $this->item->extra_fields->image_left->name;
echo $this->item->extra_fields->image_left->value;
} ?>
</div>
Furthermore,
echo $this->item->extra_fields->image_left->name;
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Klaus Fuchs
-
Topic Author
- Offline
- New Member
- Posts: 15
I think I did someting wrong agian, It doesnt show the extrafields even with ur snippet,
I fear I did another big mistake somewhere else!
1.) I added a extra field group called nh_layout
2.) I created a category called dummy-item-bilder
3.) This category is Associated with "nh_layout"
4.) I added an item in this category(nh_layout) and added a value for this extra fields
5.) Then I changed this file: /sub/joomla3/templates/my_template/html/com_k2/templates/nh_layout/item.php
Is there anything else i need to do and I didnt do?????
This is the snippet I added in this file:
blank.fuchs-net.de/templates/jsn_sunblank_free/html/com_k2/templates/nh_layout/item.php
<!-- three images in a container -->
<div class="container">
<div class="col-md-4 image">
<?php if( isset( $this->item->extra_fields->image_left ) && ( $this->item->extra_fields->image_left->value !== '') )
{echo $this->item->extra_fields->image_left->value;}
?>
</div>
<div class="col-md-4 image">
<?php if( isset( $this->item->extra_fields->image_middle ) && ( $this->item->extra_fields->image_middle->value !== '') )
{echo $this->item->extra_fields->image_middle->value; }
?>
</div>
<div class="col-md-4 image">
<?php if( isset( $this->item->extra_fields->image_right ) && ( $this->item->extra_fields->image_right->value !== '') )
{echo $this->item->extra_fields->image_right->value;}
?>
</div>
You will never hear these phrases from us:
We can't do that | I don't know what that is | I did everything on my own | That's too early | That's too late | It's too bad we couldn't work together | Let's catch up sometime | I'm sorry, I'm too busy | That was all my idea | If our competitors don't hav
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Klaus Fuchs
-
Topic Author
- Offline
- New Member
- Posts: 15
yes, where ever in the settings there is extrafields I set it to 'show'
Do I need to change the category_item.php too, or the category.php-this 2 files I did noit touch.
I do not need to display a category, only single K2 items.
very strange, it sounds so easy, but I cannot find my mistake:-(
Klaus
Thank u for helping, I buy u a drink:-)
You will never hear these phrases from us:
We can't do that | I don't know what that is | I did everything on my own | That's too early | That's too late | It's too bad we couldn't work together | Let's catch up sometime | I'm sorry, I'm too busy | That was all my idea | If our competitors don't hav
Please Log in or Create an account to join the conversation.
- Klaus Fuchs
-
Topic Author
- Offline
- New Member
- Posts: 15
blank.fuchs-net.de/index.php/sm.html
I add the snippet, like recommended but nothing to see, everything about extra fields is enabled in the categories and the item.
just want to have it soooo simple:
image | image | image
Introtext
fulltext
www link | fb link | instagram link
nothing more.
I shortende the item.php to the minimun I need. Bit still cannot pull this extrafields:-)
If someone is out there willing to help, I would also pay a small fee ( how small u ust tell) u can get access to my development site, temp. ftp etc..
the item.php file is here to download ( as plaintext)
blank.fuchs-net.de/item.txt
Thanks to all!
Klaus = exhausted:-)
You will never hear these phrases from us:
We can't do that | I don't know what that is | I did everything on my own | That's too early | That's too late | It's too bad we couldn't work together | Let's catch up sometime | I'm sorry, I'm too busy | That was all my idea | If our competitors don't hav
Please Log in or Create an account to join the conversation.
- alexandria
-
- Offline
- Senior Member
- Posts: 41
And like this, do you see extrafields ?
<div> <?php echo '<h1>between here and </h1>'; ?> </div>
<div class="container">
<?php foreach ($this->item->extra_fields as $key=>$extraField): ?>
<div class="col-md-4 image">
<?php if(($extraField->name == 'image_left') &&( $extraField->value != '')): ?>
<span class="itemExtraFieldsLabel"><?php echo $extraField->name; ?>:</span>
<span class="itemExtraFieldsValue"><?php echo $extraField->value; ?></span>
<span class="itemExtraFieldsValue"><?php echo $this->item->introtext; ?></span>
<span class="itemExtraFieldsValue"><?php echo $this->item->fulltext; ?></span>
<?php endif; ?>
</div>
<div class="clr"></div>
<div class="col-md-4 image">
<?php if(($extraField->name == 'image_middle') &&( $extraField->value != '')): ?>
<span class="itemExtraFieldsLabel"><?php echo $extraField->name; ?>:</span>
<span class="itemExtraFieldsValue"><?php echo $extraField->value; ?></span>
<?php endif; ?>
</div>
<div class="col-md-4 image">
<?php if(($extraField->name == 'image_right') &&( $extraField->value != '')): ?>
<span class="itemExtraFieldsLabel"><?php echo $extraField->name; ?>:</span>
<span class="itemExtraFieldsValue"><?php echo $extraField->value; ?></span>
<?php endif; ?>
</div>
<?php endforeach; ?>
</div>
Please Log in or Create an account to join the conversation.
- Klaus Fuchs
-
Topic Author
- Offline
- New Member
- Posts: 15
Thank u so much, now - finally - it works you made my day
Thank you so much
Klaus
You will never hear these phrases from us:
We can't do that | I don't know what that is | I did everything on my own | That's too early | That's too late | It's too bad we couldn't work together | Let's catch up sometime | I'm sorry, I'm too busy | That was all my idea | If our competitors don't hav
Please Log in or Create an account to join the conversation.
- Klaus Fuchs
-
Topic Author
- Offline
- New Member
- Posts: 15
soveld my problem!
You will never hear these phrases from us:
We can't do that | I don't know what that is | I did everything on my own | That's too early | That's too late | It's too bad we couldn't work together | Let's catch up sometime | I'm sorry, I'm too busy | That was all my idea | If our competitors don't hav
Please Log in or Create an account to join the conversation.
- alexandria
-
- Offline
- Senior Member
- Posts: 41
great !
this method come from the original item.php and you can see it too in the bottom of krikor link :
github.com/kricore/Advanced-templating-with-K2/blob/master/_inc/cheatsheet.php#L168-L173 within the method to change social links for icons.
have a nice day
Please Log in or Create an account to join the conversation.
- Forum
- K2 Community Forum
- English K2 Community
- [SOLVED] individual position of extra fields in item.php