Keyword

How to change position of an extra field?

  • Viktoria Sab
  • Viktoria Sab's Avatar Topic Author
  • Offline
  • New Member
More
14 years 4 months 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
14 years 4 months 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
14 years 4 months 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 1 month 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 1 month 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 1 month 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 1 month 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 1 month 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 1 month 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 1 month 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.


Powered by Kunena Forum