- Posts: 10
COMMUNITY FORUM
Sort by Extra-Field-Content?
- Julian
- Topic Author
- Offline
- New Member
Less
More
12 years 2 months ago - 12 years 2 months ago #103668
by Julian
Sort by Extra-Field-Content? was created by Julian
Hey,
we've got a section on our website, where we display a lot of articles with an extra field for the postal code. This section is for the presentation of several associations in germany.
Now I like to offer this list of articles sorted by the postal code. That means that I have to sort the articles according to the content of the extra field. Is there any possibility (function, extensions,...) in K2 to do that?
I am more or less lost in space and I hope that you can help me!
Best regards,
Julian
we've got a section on our website, where we display a lot of articles with an extra field for the postal code. This section is for the presentation of several associations in germany.
Now I like to offer this list of articles sorted by the postal code. That means that I have to sort the articles according to the content of the extra field. Is there any possibility (function, extensions,...) in K2 to do that?
- PHP: 5.3.13
- Joomla: 2.5.7 Stable
- K2: 2.5.7
I am more or less lost in space and I hope that you can help me!
Best regards,
Julian
Please Log in or Create an account to join the conversation.
- piotr
- Offline
- New Member
Less
More
- Posts: 13
12 years 2 months ago #103669
by piotr
Replied by piotr on topic Re: Sort by Extra-Field-Content?
Hi
I am using this module
joomcar.net/car-catalog
for sorting the content according to the extra fields.
You have to use one of the Multi-select list, Dropdown selection etc. extra fields (that the options have been added previously to the database) in order to make it work correctly and it does it's job very well.
Worth the money !
I am using this module
joomcar.net/car-catalog
for sorting the content according to the extra fields.
You have to use one of the Multi-select list, Dropdown selection etc. extra fields (that the options have been added previously to the database) in order to make it work correctly and it does it's job very well.
Worth the money !
Please Log in or Create an account to join the conversation.
- Julian
- Topic Author
- Offline
- New Member
Less
More
- Posts: 10
12 years 2 months ago - 12 years 2 months ago #103670
by Julian
Replied by Julian on topic Re: Sort by Extra-Field-Content?
Hi Piotr,
thanks for your answer and for your efforts.
I looks like this extensions offers the possibilty to select or filter articles of a category according to the content of their extra fields. This is not exactely what I am searching for.
I have got a category containing more than 100 articles. Each article got a extra field called "Postal Code". This field contains the postal code of the association described in the article.
I would like to have a option to display the complete article list of this category sorted/ordered ascending by their postal codes (which are stored in a K2 extra field).
Any ideas?
Kind regards,
Julian
thanks for your answer and for your efforts.
I looks like this extensions offers the possibilty to select or filter articles of a category according to the content of their extra fields. This is not exactely what I am searching for.
I have got a category containing more than 100 articles. Each article got a extra field called "Postal Code". This field contains the postal code of the association described in the article.
I would like to have a option to display the complete article list of this category sorted/ordered ascending by their postal codes (which are stored in a K2 extra field).
Any ideas?
Kind regards,
Julian
Please Log in or Create an account to join the conversation.
- Lefteris
- Offline
- Moderator
Less
More
- Posts: 8743
12 years 1 month ago #103671
by Lefteris
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Lefteris on topic Re: Sort by Extra-Field-Content?
@Julian
You cannot do this. The reason we do not offer that functionallity is that we store extra fields in JSON format. This means that in order to sort items, you need to first get all items, then get their extra fields and then sort them using PHP. This is something that is not supported in K2.
You cannot do this. The reason we do not offer that functionallity is that we store extra fields in JSON format. This means that in order to sort items, you need to first get all items, then get their extra fields and then sort them using PHP. This is something that is not supported in K2.
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- jeyjoo
- Offline
- New Member
Less
More
- Posts: 18
11 years 7 months ago #103672
by jeyjoo
Replied by jeyjoo on topic Re: Sort by Extra-Field-Content?
We just found a way of doing this in k2. The solution is an override of the template, but just one line is added.
We have an events section here www.vidalatinaweb.com/it/eventi/congressi-ed-eventi , that has an extra field "date". we wanted to order by this field (this would work for postcode too).
Solution
Create a menu item linking to an empty article.
Create a module k2 contents that selects from your k2 category, that appears on your new empty page
For "Order by", select "Title alphabetical" - we use this as we are going to hack it - so it needs to be an order you will not use for any other module
Open the file modules/mod_k2_content/helper.php
on line 195 find the code
case 'alpha' :
$orderby = 'i.title DESC';
break;
and replace with:
case 'alpha' :
$orderby = 'i.extra_fields DESC';
break;
This will work if you only have one extra field. If you have more than one extra field, you will have to modify the solution, but I think you get the general idea.
Regards
Jeyjoo
We have an events section here www.vidalatinaweb.com/it/eventi/congressi-ed-eventi , that has an extra field "date". we wanted to order by this field (this would work for postcode too).
Solution
Create a menu item linking to an empty article.
Create a module k2 contents that selects from your k2 category, that appears on your new empty page
For "Order by", select "Title alphabetical" - we use this as we are going to hack it - so it needs to be an order you will not use for any other module
Open the file modules/mod_k2_content/helper.php
on line 195 find the code
case 'alpha' :
$orderby = 'i.title DESC';
break;
and replace with:
case 'alpha' :
$orderby = 'i.extra_fields DESC';
break;
This will work if you only have one extra field. If you have more than one extra field, you will have to modify the solution, but I think you get the general idea.
Regards
Jeyjoo
Please Log in or Create an account to join the conversation.
- George Skordilis
- Offline
- New Member
- Web Enthusiast
11 years 6 months ago #103673
by George Skordilis
I'd be glad to be of help to anyone, regarding services related to:
Web Design - Development - Support / Mobile Apps / Linux-based cPanel Servers
---
www.gsproject.gr
Replied by George Skordilis on topic Re: Sort by Extra-Field-Content?
Dear jeyjoo hello!
I need to implement this on a website with multiple extra_fields. Is there any chance you could help me out with that, as I'm no developer myself?
Thank you very much in advance!
I need to implement this on a website with multiple extra_fields. Is there any chance you could help me out with that, as I'm no developer myself?
Thank you very much in advance!
I'd be glad to be of help to anyone, regarding services related to:
Web Design - Development - Support / Mobile Apps / Linux-based cPanel Servers
---
www.gsproject.gr
Please Log in or Create an account to join the conversation.
- Julian
- Topic Author
- Offline
- New Member
Less
More
- Posts: 10
11 years 4 months ago #103674
by Julian
Replied by Julian on topic Re: Sort by Extra-Field-Content?
Hello jeyjoo,
thank you very much! Works like a charm. I've used the "Random" sort-option coz' it's never used on our page at all.
I hope sorting by extra field value will be implemented to K2 in near future. It would be very useful and avoids hacks like this.
But for now I am very happy with jeyjoo's solution.
Cheers,
Julian
thank you very much! Works like a charm. I've used the "Random" sort-option coz' it's never used on our page at all.
I hope sorting by extra field value will be implemented to K2 in near future. It would be very useful and avoids hacks like this.
But for now I am very happy with jeyjoo's solution.
Cheers,
Julian
Please Log in or Create an account to join the conversation.
- Renzo
- Offline
- New Member
Less
More
- Posts: 10
10 years 5 months ago #103675
by Renzo
Replied by Renzo on topic Re: Sort by Extra-Field-Content?
Hi, all.
This worked form me with joomla 2.5
Now after moving on joomla 3 it does not work any more.
Have you any idea of what it is changed on extra fields?
Has anybody solved for multiple extra fields?
Thank you
This worked form me with joomla 2.5
Now after moving on joomla 3 it does not work any more.
Have you any idea of what it is changed on extra fields?
Has anybody solved for multiple extra fields?
Thank you
Please Log in or Create an account to join the conversation.
- eyeweiss
- Offline
- New Member
Less
More
- Posts: 7
10 years 5 months ago #103676
by eyeweiss
Replied by eyeweiss on topic Re: Sort by Extra-Field-Content?
While the file to be edited was earlier found in
in
I now found the linesmodules/mod_k2_content/helper.php
case 'alpha' :
$orderby = 'i.title';
break;
templates\com_k2\models\itemlist.php
Please Log in or Create an account to join the conversation.