Keyword

How to change position of an extra field?

  • Viktoria Sab
  • Viktoria Sab's Avatar Topic Author
  • Offline
  • New Member
More
15 years 4 weeks ago #82342 by Viktoria Sab
How to change position of an extra field? was created by Viktoria Sab
Hi, Has anybody faced with the problem of changing the position of a particular extra field? 
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.

More
15 years 4 weeks ago #82343 by Simon Wells
Replied by Simon Wells on topic How to change position of an extra field?
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.

  • Viktoria Sab
  • Viktoria Sab's Avatar Topic Author
  • Offline
  • New Member
More
15 years 2 weeks ago #82344 by Viktoria Sab
Replied by Viktoria Sab on topic How to change position of an extra field?
Thanks a lot, Simon. Your advice was very useful.

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
Attachments:

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

More
14 years 9 months ago #82345 by Oceanwatcher
Replied by Oceanwatcher on topic How to change position of an extra field?
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.

More
14 years 9 months ago #82346 by william white
Replied by william white on topic How to change position of an extra field?
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.

More
14 years 9 months ago #82347 by william white
Replied by william white on topic How to change position of an extra field?
Also, to skip the extra field you dont want edit in the override item.php and put something like
{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.

More
14 years 9 months ago #82348 by Oceanwatcher
Replied by Oceanwatcher on topic How to change position of an extra field?
William,

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.

More
14 years 9 months ago #82349 by william white
Replied by william white on topic How to change position of an extra field?
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.

More
14 years 9 months ago #82350 by Oceanwatcher
Replied by Oceanwatcher on topic How to change position of an extra field?
Yes, I guessed that part - same as some other things in the Linux world. This is how far I got on my own :-) The Author info is inserted in the author part as there is no point in showing it if no name exist for the author...




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.

More
14 years 9 months ago #82351 by Oceanwatcher
Replied by Oceanwatcher on topic How to change position of an extra field?
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.

More
14 years 9 months ago #82352 by Craig Pearson
Replied by Craig Pearson on topic How to change position of an extra field?
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.

More
14 years 9 months ago #82353 by Craig Pearson
Replied by Craig Pearson on topic How to change position of an extra field?
Figured out a way.

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.

More
14 years 9 months ago #82354 by Oceanwatcher
Replied by Oceanwatcher on topic How to change position of an extra field?
Great news Craig!

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.

More
14 years 9 months ago #82355 by william white
Replied by william white on topic How to change position of an extra field?
Another way would be to go into the foreach loop for xtra fields. and put and if statement around the part that displays the name and value and say something like
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.


Powered by Kunena Forum