Keyword

Trying to filter data

More
10 years 2 months ago #130005 by David
Trying to filter data was created by David
Hello,

I am currently working on a wbesite that'll have about 500 items.
All this data needs to be sorted. For instance, people would like to sort hotel according to their prices or the number of rooms they use.

I have been searching for some days and cannot find a solution.

My first guess have been using the onK2BeforeQuerySet trigger but I don't feel like swapping SQL on fly according to user state.

More over, extra fields are stored within JSON makes it real hard to filter through sql, is there some way I can "export" the data to another table ? Is there a trigger somewhere before saving extra fields ?

Thanks in advance for your replies :)

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

More
10 years 2 months ago #130006 by Lefteris
Replied by Lefteris on topic Re: Trying to filter data
Hi. Extra fields in K2 are used to display extra information. Since they are in JSON format you cannot query directly the database. If you want to convert them to normal SQL data you need to first read the data with PHP and then store them in a different table. For what you want to do it would be better to use K2 plugins instead of extra fields. A K2 Plugin can provide also custom fields and then it's up to the developer to decide where to save them. When an item is saved the "onAfterK2Save" event is triggered to all K2 plugins. There you can grab your data and store it wherever you like. You can always look at the example K2 plugin source code at github.com/joomlaworks/example-k2-plugin . Finally, note that there are also some extensions out there which provide filtering of items based on the extra fields. Since your site has only 500 items such an extension might be a good solution for you.

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

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

More
10 years 2 months ago #130007 by David
Replied by David on topic Re: Trying to filter data
Thanks for the answer. The paid module doesn't do much I need as, for instance, I'll need to link a hotel to a restaurant for example and then find restaurants that are hotels... (Hope you got the point.)

I am currently understanding all the plugin. And this can give great forms. However, every fields I make are shown on every item.

Is it possible to restrict a fieldset to specific categories ?

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 2 months ago #130008 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: Trying to filter data
You have to add that as an option to the plugin.
Btw have you looked at any "related items" or similar type extensions?

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

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


Powered by Kunena Forum