Keyword

Extra Field list order

More
7 years 11 months ago #153894 by Bobby
Extra Field list order was created by Bobby
Good evening all.

I have recently been handed an existing site that is running ver 2.6.x of K2 and I need some assistance.

There is an 'authors' extra field with names entered in the Extra Fields Administrator as below..

John Smith (ID 1)
Susan Jones (ID 2)
Brad Helms (ID 3)

When I go to add a K2 Item, the extra field multi-select for authors is now in alphabetical order (which is helpful) and allows me to select multiple authors in any order one at a time. But, when the item is saved, the author ids are inserted into the database in order of their alphabetical listing ({3,1,2}), not the order in which they were selected. I need them to stay in the order that they are selected. If I select Susan Jones, then Brad Helms, it should be saved as {2,3}.

Thank you in advance for any assistance you can offer.

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 11 months ago #153903 by Krikor Boghossian
Replied by Krikor Boghossian on topic Extra Field list order
Hello,
Unfortunately this is not possible. This it the default behaviour of the multiple select element.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

More
7 years 11 months ago #153926 by Bobby
Replied by Bobby on topic Extra Field list order
Thank you Krikor. Can you think of any other possible option to accomplish what I need? Perhaps using JQuery to submit the selections vs. using the <select> values to submit in the form?

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 11 months ago #153936 by Krikor Boghossian
Replied by Krikor Boghossian on topic Extra Field list order
I think a plugin is needed where you can use jQuery in order to reorder the fields.
There are extensions in the JED which register new extrafields, maybe you can find something useful in the JED.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

More
7 years 10 months ago #153973 by Bobby
Replied by Bobby on topic Extra Field list order
I think I may have a work-a-round. I added an extra field that will contain the sort and prior to submitting, the order of the authors is placed in the extra field. All of that seems to be working now except the extra field is not showing up in my custom item.php. The extra field as been added to a group and assigned to a category. Is there somewhere else that the extra field needs to initiated? I'm pulling my hair over something that appears to be so simple.

Again, thank you for your assistance Krikor.

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 10 months ago #154075 by Krikor Boghossian
Replied by Krikor Boghossian on topic Extra Field list order
Hmm, I assume this field belongs to the same group as the others, right?
What type is that extrafield?
Also, have you modified your templates, can you share some code if you did?

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

More
7 years 10 months ago #154119 by Bobby
Replied by Bobby on topic Extra Field list order
Yes, it belongs to the same group and it is a plain text field. My work-around is to use JQuery to save the order into this textfield and then just use the text field to determine the author order on the site.

I am getting into this part way through someone else modifying the templates, so I honestly have no idea what they may have done prior.

The com_k2 > templates > default > item.php in my theme doesn't appear to be excluded anything, but when I do

foreach ($this->item->extra_fields as $key=>$extraField)
{
echo $extraField->id;
}

My newly added extrafield is not in the list. It's odd, it is like the IDs of the existing extrafields where hard coded into the query and that's preventing any new ones from getting through. Is that possible?

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 10 months ago #154127 by Krikor Boghossian
Replied by Krikor Boghossian on topic Extra Field list order

My newly added extrafield is not in the list. It's odd, it is like the IDs of the existing extrafields where hard coded into the query and that's preventing any new ones from getting through. Is that possible?


Not really, unless the field does not hold a value, can you check the db to make sure that the field is not empty?

Btw you should use overrides:
getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

More
7 years 10 months ago #154176 by Bobby
Replied by Bobby on topic Extra Field list order
Yes, I have verified that the values for the new extra field are saving to the DB. Anything else that you can think of?

Thanks for the info about the sub templates....I will have a look.

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

More
7 years 10 months ago #154180 by Bobby
Replied by Bobby on topic Extra Field list order
In an attempt to see if it was my template preventing it from displaying for some reason, I just removed my item.php from the template directory. Allowing the default item.php to load and still nothing. Is there another setting in the Joomla admin that needs to be turned on to all the extra field to be visible? Publish is checked for the extra field.

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


Powered by Kunena Forum