- Posts: 4
COMMUNITY FORUM
Display specific extra fields
- boulder606
-
Topic Author
- Offline
- New Member
Less
More
9 years 4 months ago #149959
by boulder606
Display specific extra fields was created by boulder606
Hello,
i need to display specific extra fields. How can I do this? Would that be something like:
<?php echo $item->extra_fields[0]->value; ?>
<?php echo $item->extra_fields[1]->value; ?>
As well how would I be able to add different classes to each field?
Thanks
i need to display specific extra fields. How can I do this? Would that be something like:
<?php echo $item->extra_fields[0]->value; ?>
<?php echo $item->extra_fields[1]->value; ?>
As well how would I be able to add different classes to each field?
Thanks
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- User
Less
More
9 years 4 months ago #149964
by Krikor Boghossian
Replied by Krikor Boghossian on topic Display specific extra fields
You can do it based on the alias:
github.com/kricore/Advanced-templating-with-K2/blob/master/_inc/cheatsheet.php#L104-L109
You can also add a <div> or a <span> with the class you want that wraps the field.
github.com/kricore/Advanced-templating-with-K2/blob/master/_inc/cheatsheet.php#L104-L109
You can also add a <div> or a <span> with the class you want that wraps the field.
Please Log in or Create an account to join the conversation.
- boulder606
-
Topic Author
- Offline
- New Member
Less
More
- Posts: 4
9 years 4 months ago #149974
by boulder606
Replied by boulder606 on topic Display specific extra fields
Thanks for the last reply but it seems I do something wrong
Here the code i used
Error:
Parse error: syntax error, unexpected '!' in .......
Here the code i used
<?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> -->
<?php if($this->item->params->get('itemExtraFields') && count($this->item->extra_fields)): ?
<?php if( isset( $this->item->extraFields->wxxx->value ) && ( $this->item->extraFields->wxxx->value ! == '') )
{
$this->item->extraFields->wxxx->name;
$this->item->extraFields->wxxx->value;
}
<?php endif; ?>
<div class="clr"></div>
</div>
<?php endif; ?>
<div class="clr"></div>
</div>
<?php endif; ?>
Error:
Parse error: syntax error, unexpected '!' in .......
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- User
Less
More
9 years 4 months ago #149978
by Krikor Boghossian
Replied by Krikor Boghossian on topic Display specific extra fields
You forgot to close the PHP brackets here:
It should be:
$this->item->extraFields->wxxx->value;
}
It should be:
$this->item->extraFields->wxxx->value;
} ?>
Please Log in or Create an account to join the conversation.
- boulder606
-
Topic Author
- Offline
- New Member
Less
More
- Posts: 4
9 years 4 months ago #149982
by boulder606
Replied by boulder606 on topic Display specific extra fields
Yes, I tried this :
still I get the error:
Parse error: syntax error, unexpected '!' in
Using the last version from K2 just in case you need to know
// Render a specific extrafield
<?php if ( isset( $this->item->extraFields->wxxx->value ) && ( $this->item->extraFields->wxxx->value ! == '') )
{
$this->item->extraFields->wxxx->name;
$this->item->extraFields->wxxx->value;
} ?>
still I get the error:
Parse error: syntax error, unexpected '!' in
Using the last version from K2 just in case you need to know
Please Log in or Create an account to join the conversation.
- boulder606
-
Topic Author
- Offline
- New Member
Less
More
- Posts: 4
9 years 4 months ago #149987
by boulder606
Replied by boulder606 on topic Display specific extra fields
I worked it out. here the solution for someone who might want to do the same:
<?php if($this->item->extraFields->wlang->value != ''): ?>
<div class="itemExtraFieldswrapper">
<div class="itemExtraFieldsLabel"> <?php echo $this->item->extraFields->wlang->name; ?></div>
<div class="itemExtraFieldsValue"><?php echo $this->item->extraFields->wlang->value; ?></div>
</div>
<?php endif; ?>
that includes some div wrappers as well when you want to style them
<?php if($this->item->extraFields->wlang->value != ''): ?>
<div class="itemExtraFieldswrapper">
<div class="itemExtraFieldsLabel"> <?php echo $this->item->extraFields->wlang->name; ?></div>
<div class="itemExtraFieldsValue"><?php echo $this->item->extraFields->wlang->value; ?></div>
</div>
<?php endif; ?>
that includes some div wrappers as well when you want to style them
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- User
Less
More
9 years 4 months ago #149994
by Krikor Boghossian
Replied by Krikor Boghossian on topic Display specific extra fields
Yeap i had forgot some trailing whitespace.
Thanks :)
Thanks :)
Please Log in or Create an account to join the conversation.