PHP with Plug-in order

Hello,

is it possible to run PHP for each element in list? I would like to update a second data item to get the same sk_id (sort key id / order plugin), that has the same gk_id (group key id: group different languages).

I am using de_DE and en_EN language on my site and when I order list with drag & drop, I would like list for another language to get the same order.

pk_id | gk_id | sk_id | label | language
1 | 1 | 1 | item1 DE | de_DE
2 | 1 | 1 | item1 EN | en_EN
3 | 2 | 2 | item2 DE | de_DE
4 | 2 | 2 | item2 EN | en_EN
5 | 3 | 3 | item3 DE | de_DE (move to position 1 drag & drop)
6 | 3 | 3 | item3 EN | en_EN (move to position 1 using PHP)

pk_id | gk_id | sk_id | label | language
1 | 1 | 3| item1 DE | de_DE
2 | 1 | 3 | item1 EN | en_EN
3 | 2 | 2 | item2 DE | de_DE
4 | 2 | 2 | item2 EN | en_EN
5 | 3 | 1 | item3 DE | de_DE
6 | 3 | 1 | item3 EN | en_EN
 
What I could possibly do is add either one or two options to the order plugin, for "Pre-Order Query" and "Post-Order Query", and allow for some placeholder replacements like {dragged} (the PK of the re-ordered element) and {oldorder}, {neworder}.

Then, if I'm understanding you right, you would be able to do a post-order query of something like ...

Code:
UPDATE yourtable SET sk_id = '{neworder}' WHERE 'sk_id' = '{oldorder}'

... which would find any rows with the sk_id (order element) that was the same as the row just moved, and change it to the new order value.

That would take half an hour or so to code and test, which would pretty much use up your support for the month.

-- hugh
 
Tried some more. It looks like sorting will be performed on all data in the db table instead of just those rows, that are populated in the current table. Tried a MySQL trigger, but currently won't work because all data in table will get a new order id.
 
Let me make sure I understand what you are trying to do. You have data which is ordered in pairs. When you re-order for one of the pair, you want the other to get the same new order number?

I'm not even sure if the plugin as-is will preserve pairings, rather than re-sequencing. So if you have 1,1,2,2,3,3 and then re-order, it may become 1,2,3,4,5,6. Never tried that.

Code:
 It looks like sorting will be performed on all data in the db table instead of just those rows, that are populated in the current table

Not sure what you mean by "all data in the table" versus "populated in the current table". Do you mean versus "displayed with the currently active filters"?

-- hugh
 
"displayed with the currently active filters"? Yes...

1,1,2,2,3,3,x,x should become 2,2,1,1,3,3,x,x

...in this example, only first second and third pair have changed value, because x,x are not in filtered data. With the current re-order, all rows in db get a new order id 1,2,3,4,5,6
 
Yup, looks like we call the main list model reorder() method at the end of the plugin, which will "compact" and renumber every row in the table, which if why I figured that paired ordering wouldn't survive ordering.

I could maybe add an option as to whether we should run that or not. Which could be an expensive operation on a large table, so maybe worth adding that anyway.

I'm happy to work with you to get the order plugin working to suit your needs, but it could be at least middle of next week before I have the time to work on it. I'm presenting at Joomla Day in Houston this weekend, driving there (750 miles) on Friday, got some paid custom work I have to finish before I leave.

-- hugh
 
no hurry...I looked at order.php myself, but to keep track of core changes after update would get tricky at some point.

Option to avoid reordering the whole table or just the data that has been filtered in the frontend table would be nice. then I could apply a MySQL Trigger like:

pk_id = primary key id
uk_id = user key id
sk_id = sort key id: sort data
gk_id = group key id: group data

Code:
CREATE TRIGGER trigger_myTable___sk_id AFTER UPDATE
ON myTable
FOR EACH ROW
BEGIN
UPDATE myTable SET sk_id = NEW.sk_id WHERE gk_id = OLD.gk_id AND uk_id = OLD.uk_id AND language <> OLD.language;
END;$$
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top