Content creation and ordering

For Joomla! 3.x Coding related discussions, you could also use: http://groups.google.com/group/joomla-dev-general

Moderators: ooffick, General Support Moderators

Forum rules
Locked
User avatar
pelloq1
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 145
Joined: Sat Dec 16, 2006 7:42 am
Location: Switzerland

Content creation and ordering

Post by pelloq1 » Tue Jun 07, 2016 12:26 pm

Hello,

I have created a custom component, that use backend listings (extends from JModelList). Exactly like the core joomla com_content, my extension store a list of items.

My items are chapters of a documentation imported books (a lot of books and chapters), the structure is like:

Code: Select all

 0. Book title 
 1 title 
 1.1 title
 1.2 title
 .... More than 5000 records. 
And each record have several 'core' supported field, like state, Id, title, content and ordering, and some custom fields like Id_parent, name, content, short_content, ...

All is fine... Until one book as been modified by its author, and have new chapters.

Now in the backend listing. I added a button to each line named 'insert child article'. This button il like the 'new' button, except it pass 2 custom values in the url to prefill the parent_id field, and the current ordering.

All is fine, I can create child item.

BUT, now my problem is the ordering. I want that the new inserted item, goes not at end of listing (ordering = getMaxOrder()..), but to the next ordering number just after the line from where I created this child.

Sample:

Code: Select all

 23.4 Title abc (ordering 3456) [insert child]
 23.5 Title xyz (ordering 3457) [insert child]
Now I need a new chapter 23.4.1, with ordering 2357, and the 23.5 become 2358, and all next items will shift +1.

Is there an easy way to do this with the joomla api?

I hope it's clear to understand ...

Thanks you, Cédric
Last edited by pelloq1 on Tue Jun 07, 2016 12:46 pm, edited 3 times in total.

itoctopus
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4025
Joined: Mon Nov 25, 2013 4:35 pm
Location: Montreal, Canada
Contact:

Re: Content creation and ordering

Post by itoctopus » Tue Jun 07, 2016 12:43 pm

If you have child items, then you will need to develop a concept like that of the #__assets table, where you have the lft and rgt (left and right) fields. Check the #__assets table on what these fields mean, and avoid the temptation to store your data there as an inflated #__assets table can seriously impact the performance of your website.
http://www.itoctopus.com - Joomla consulting at its finest
https://twitter.com/itoctopus - Follow us on Twitter

User avatar
pelloq1
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 145
Joined: Sat Dec 16, 2006 7:42 am
Location: Switzerland

Re: Content creation and ordering

Post by pelloq1 » Tue Jun 07, 2016 4:47 pm

Thanks you, my database structure and he application are already running, I cannot change now the database structure ...

Did you do not have another solution?

User avatar
pelloq1
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 145
Joined: Sat Dec 16, 2006 7:42 am
Location: Switzerland

Re: Content creation and ordering

Post by pelloq1 » Tue Jun 07, 2016 7:45 pm

I found this about left and right, but as said I cannot change the structure.
http://mikehillyer.com/articles/managin ... -in-mysql/

User avatar
pelloq1
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 145
Joined: Sat Dec 16, 2006 7:42 am
Location: Switzerland

Re: Content creation and ordering

Post by pelloq1 » Wed Jun 08, 2016 10:27 am

Currently I found a (poor) workaround.

In the dedicated table extens JTable, in the check function I set manually the ordering value (based on the parent or the borther), and at next manual reordering, joomla reorder all.


Locked

Return to “Joomla! 3.x Coding”