- Posts: 7
COMMUNITY FORUM
How to change position of an extra field?
- Viktoria Sab
-
Topic Author
- Offline
- New Member
We ought to implement news items, that have Title and Subtitle going directly one after another. As it is now, we can simply put only a title of a news item. We decided to solve the problem with the extra fields option, adding specific field "Subtitle" to the news category. Unfortunately our extra field appears at the bottom of an article as a line of additional information. So, there are 2 questions:
- How to put subtitle to the top (bellow Title) in the Front-end?
- How to make an additional field at the back-end, right at the first tab, bellow Title, when creating new item?
I'll be grateful a lot for any suggestions.
Please Log in or Create an account to join the conversation.
- Simon Wells
-
- Offline
- Platinum Member
- Posts: 955
Open up item.php and search forThis whole block is what you need to be moving and place it directly after
As for your second option, I dont understand your request, please explain.
Simon
K2 Support
Please Log in or Create an account to join the conversation.
- Viktoria Sab
-
Topic Author
- Offline
- New Member
- Posts: 7
Regarding my second option, perhaps I was unable to explain it properly :). Sorry, English is not my native lang. I think it would be better to attach a printscreen of Item editing page, where I've figured my idea. Please, take a look.
The point is to place "subtitle" text field directly after Title and Title Alias. Is there any way to change back-end template of Item editing? I'm worried, that a website editors will always fluster where and how to add subtitle to an item. :)
Furthermore, I have another question concerning extra-field "Subtitle", but I think it would be better to post it as separate theme for disccussion, for it is more about an item property "Related items" and extra fields... Could you be so kind to cast a glance at? Thanks in advance.
Viki
K2Joom said:You need to modify the item.php file located in components/com_k2/templates/default, but make a backup of it first. Open up item.php and search forThis whole block is what you need to be moving and place it directly after
As for your second option, I dont understand your request, please explain.
Simon
K2 Support
Please Log in or Create an account to join the conversation.
- Oceanwatcher
-
- Offline
- Elite Member
- Posts: 175
Did you ever find out how to put one single extra field (not the whole bunch...) a different place than at the bottom of the article?
This means we need to have a way to identify this particular field and add the code for it where we want it.
Also, this field will have to be omitted at the bottom of the article, so it is not listed twice.
Please Log in or Create an account to join the conversation.
- william white
-
- Offline
- Platinum Member
- Posts: 3722
$custom = $this->item->extra_fields;
and then addressing extra fields for the item like
echo $custom[1]->value; depending on the position, 0, 1,2,3,4 etc in the array
experiment with this code
Svein Wisnaes said:Viktoria (and Simon),
Did you ever find out how to put one single extra field (not the whole bunch...) a different place than at the bottom of the article?
This means we need to have a way to identify this particular field and add the code for it where we want it.
Also, this field will have to be omitted at the bottom of the article, so it is not listed twice.
Please Log in or Create an account to join the conversation.
- william white
-
- Offline
- Platinum Member
- Posts: 3722
{pseudocode}
phpif this->extrafield->name="fieldyouwantto skip"
else
let the rest of the existing foreach loop run
phpendif
endfor
something like that should do the trick
William White said:you can get the extra fields like this if it suits your needs
$custom = $this->item->extra_fields;
and then addressing extra fields for the item like
echo $custom[1]->value; depending on the position, 0, 1,2,3,4 etc in the array
experiment with this code
Svein Wisnaes said:Viktoria (and Simon), Did you ever find out how to put one single extra field (not the whole bunch...) a different place than at the bottom of the article?
This means we need to have a way to identify this particular field and add the code for it where we want it.
Also, this field will have to be omitted at the bottom of the article, so it is not listed twice.
Please Log in or Create an account to join the conversation.
- Oceanwatcher
-
- Offline
- Elite Member
- Posts: 175
I saw something like this in another post and I am pretty sure you were the one answering there as well :-)
As I am not a programmer, I will have to do a bit of experimenting to get this one right... I only have one extra field for this category. So that should leave me with a 1? Does it make any difference what kind of extra field? Mine is a visual editor...
William White said:you can get the extra fields like this if it suits your needs $custom = $this->item->extra_fields;
and then addressing extra fields for the item like
echo $custom[1]->value; depending on the position, 0, 1,2,3,4 etc in the array
experiment with this code
Svein Wisnaes said:Viktoria (and Simon), Did you ever find out how to put one single extra field (not the whole bunch...) a different place than at the bottom of the article?
This means we need to have a way to identify this particular field and add the code for it where we want it.
Also, this field will have to be omitted at the bottom of the article, so it is not listed twice.
Please Log in or Create an account to join the conversation.
- william white
-
- Offline
- Platinum Member
- Posts: 3722
If a visual editor... field is a text field that you can add html to it should work because its text. You could run into formatting problems if you use date or logical fields, but i havent tried that yet
please see my friend request
Please Log in or Create an account to join the conversation.
- Oceanwatcher
-
- Offline
- Elite Member
- Posts: 175
William White said:If there is only one extra field it will be referenced as [0]. this is because arrays start with 0 for the first element. If a visual editor... field is a text field that you can add html to it should work because its text. You could run into formatting problems if you use date or logical fields, but i havent tried that yet
please see my friend request
Please Log in or Create an account to join the conversation.
- Oceanwatcher
-
- Offline
- Elite Member
- Posts: 175
The strange thing is that even if I do not have any condition for showing it, it still responds to the Extrafields setting for the category. But as I only have this single extrafield in this project so far, I commented out the extrafields code at the bottom of the page. So It works :-)
Will get back with more info if I find something out!
Please Log in or Create an account to join the conversation.
- Craig Pearson
-
- Offline
- Junior Member
- Posts: 36
Svein Wisnaes said:Looks like this code did the trick so far! Had to clean cache to get it to show.
The strange thing is that even if I do not have any condition for showing it, it still responds to the Extrafields setting for the category. But as I only have this single extrafield in this project so far, I commented out the extrafields code at the bottom of the page. So It works :-)
Will get back with more info if I find something out!
Please Log in or Create an account to join the conversation.
- Craig Pearson
-
- Offline
- Junior Member
- Posts: 36
After you added the isolated fields to your item.php (and I supposed others if you want it to show) find the Additional info area in that file (around 261). Do this to the code (see attachment)
k2codefile.txt
This will add on to the style class using the name of the field you created - now you have an individual style per line.
In my case that would give me .group1Subtitle - I can change the colour or visibility hidden now but if you want to display none then you need to add this whole class to the K2 stylesheet:
div.itemExtraFields ul li.group1Subtitle { display: none; }
To use a display none
Craig Pearson said:This is great, and it works but my question is - is it possible to still keep the Additional info fields below but omit the one you have isolated? Svein Wisnaes said:Looks like this code did the trick so far! Had to clean cache to get it to show. The strange thing is that even if I do not have any condition for showing it, it still responds to the Extrafields setting for the category. But as I only have this single extrafield in this project so far, I commented out the extrafields code at the bottom of the page. So It works :-) Will get back with more info if I find something out!
Please Log in or Create an account to join the conversation.
- Oceanwatcher
-
- Offline
- Elite Member
- Posts: 175
Right now, I only needed one field, so I just commented out the rest, but I might have to bring it back and use your method later. Thanks! :-)
And Viktoria - sorry for hijacking your topic here, but as it all was in the same direction, I hope you do not mind too much :-)
Craig Pearson said:Figured out a way.
Please Log in or Create an account to join the conversation.
- william white
-
- Offline
- Platinum Member
- Posts: 3722
if this extra field value != "name of field you want to leave out"
do the display
endif
this would work nicely in an override.....
If you have created another css style with the above code.txt then you could use css4k2 and have the hidden in the override_style.css as well
Please Log in or Create an account to join the conversation.