- Posts: 142
COMMUNITY FORUM
How to style every single extra field?
- theant
- Topic Author
- Offline
- Premium Member
Less
More
12 years 4 months ago - 12 years 4 months ago #101031
by theant
How to style every single extra field? was created by theant
Hello
I need to style differently every single extra field, is it possible?
I need to style differently every single extra field, is it possible?
Please Log in or Create an account to join the conversation.
- theant
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 142
12 years 4 months ago #101032
by theant
Replied by theant on topic Re: How to style every single extra field?
Is it not possible?
Please Log in or Create an account to join the conversation.
- william white
- Offline
- Platinum Member
Less
More
- Posts: 3722
12 years 4 months ago #101033
by william white
Replied by william white on topic Re: How to style every single extra field?
The extra fields are designed to display in a two column format.
You can find this in either item.php or category_item.php of your override directory if you are using an override. (see docs above for k2 templating)
In order to style each extra field differently you will have to address the extra fields one at a time and apply the style you want in the item.php and the css files
Try creating a variable and address it like this $custom = $this->item->extra_fields; and then addressing extra fields for the item like echo $custom[1]->value; with your own divs around them
You can find this in either item.php or category_item.php of your override directory if you are using an override. (see docs above for k2 templating)
In order to style each extra field differently you will have to address the extra fields one at a time and apply the style you want in the item.php and the css files
Try creating a variable and address it like this $custom = $this->item->extra_fields; and then addressing extra fields for the item like echo $custom[1]->value; with your own divs around them
Please Log in or Create an account to join the conversation.
- theant
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 142
12 years 4 months ago #101034
by theant
Replied by theant on topic Re: How to style every single extra field?
Thanks a lot William White and sorry for the delay, I din't get the forum notification for your reply.
Please, can you help me to understand where to try creating a variable and address it like this $custom = $this->item->extra_fields; ?
Please, can you help me to understand where to try creating a variable and address it like this $custom = $this->item->extra_fields; ?
Please Log in or Create an account to join the conversation.
- william white
- Offline
- Platinum Member
Less
More
- Posts: 3722
12 years 4 months ago #101035
by william white
Replied by william white on topic Re: How to style every single extra field?
this would go in either your item.php or your category_item.php of a k2 template override
Please Log in or Create an account to join the conversation.
- theant
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 142
12 years 3 months ago #101036
by theant
Replied by theant on topic Re: How to style every single extra field?
It seems too much difficult for me, I'm a designer :(
I suppose this is the part of item.php :
but i have no idea how to do.
I suppose this is the part of item.php :
<?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; ?>">
<span class="itemExtraFieldsLabel"><?php echo $extraField->name; ?>:</span>
<span class="itemExtraFieldsValue"><?php echo $extraField->value; ?></span>
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
<div class="clr"></div>
</div>
<?php endif; ?>
but i have no idea how to do.
Please Log in or Create an account to join the conversation.
- Peter
- Offline
- New Member
Less
More
- Posts: 19
11 years 11 months ago - 11 years 11 months ago #101037
by Peter
Replied by Peter on topic Re: How to style every single extra field?
I have a solution... might not be perfect, but it seems to work.
In item.php on line 262, I changed this:
to this:
You'll want to avoid using spaces in the names of your Extra Fields.
After doing this, you can then add classes to your CSS like this:
.itemExtraFieldsValue .NameOfYourExtraField {
}
In item.php on line 262, I changed this:
<span class="itemExtraFieldsValue"><?php echo $extraField->value; ?></span>
to this:
<span class="itemExtraFieldsValue <?php echo $extraField->name; ?>"><?php echo $extraField->value; ?></span>
You'll want to avoid using spaces in the names of your Extra Fields.
After doing this, you can then add classes to your CSS like this:
.itemExtraFieldsValue .NameOfYourExtraField {
}
Please Log in or Create an account to join the conversation.
- william white
- Offline
- Platinum Member
Less
More
- Posts: 3722
11 years 11 months ago #101038
by william white
Replied by william white on topic Re: How to style every single extra field?
@peter - Nice!
the new syntax of xtra fields allows a lot
the new syntax of xtra fields allows a lot
Please Log in or Create an account to join the conversation.
- Michael Lundie
- Offline
- New Member
Less
More
- Posts: 1
11 years 7 months ago #101039
by Michael Lundie
Replied by Michael Lundie on topic Re: How to style every single extra field?
This is really useful - cheers! If you want a little more control over the resulting CSS class you could use the 'alias' value instead.
Log in or Create an account to join the conversation.
- Roman
- Offline
- New Member
Less
More
- Posts: 3
11 years 5 months ago - 11 years 5 months ago #101040
by Roman
Replied by Roman on topic Re: How to style every single extra field?
Hi everyone!
I have another problem. How to style every single select type value in extrafields? For example: option value 1 - style 1, option value 2 - style 2 and so on... How to get thase values 1,2,3..?
I have another problem. How to style every single select type value in extrafields? For example: option value 1 - style 1, option value 2 - style 2 and so on... How to get thase values 1,2,3..?
Please Log in or Create an account to join the conversation.