Problems, need help? Have a tip or advice? Post it here.
6 posts Page 1 of 1
Hi!
Maybe this is trivial, but i'm stuck. A hint or kick would help a lot. :D

Here is the canonical example:
A page in Album Template is related to pages in Songs Template. In Album Template we choose songs, that belong to this album. I need to provide special order of the songs by track number.
And some songs, of course, appear in other Albums with different track number.

A song 'Let it be' appears in Album A by the number 5 among other songs, and in Album B by the number 2 among the others. :cry: How to list related songs of Albums in correct order? I guess another template might be needed..

I would like to have an option to do all the operations in a simple way, if possible.
Hi trendoman,

In conventional RDBMS design, what you are looking for is generally provided by the 'associative' table between two 'many-to-many' entities.

Unfortunately, that is currently not available with Couch.
I must add, though, that I have pondered over this very problem and intend to do something about it in the near future. For now, I'm sorry, you'll have to craft some kind of a workaround.
Hi, KK :mrgreen:

Thank you for letting me know. Seems, you have something in mind about this..
I'm actually curious about the following setup:

A template with Articles (aka blog), or code chunks, or snippets.
Another template is with webpage layouts. The idea is to relate chosen snippets with chosen layout, and assign snippet to a certain part of layout.

A webpage can reuse a snippet, placed in different places. That is why I need to store info with exact number. Maybe fetching can be done with repeatables, so each page-snippet would explicitly have data like page 1 - place 1, page 2 - place 6. The downside is a hand-work, and also this is not tested.
Any update on this?
Solution 1
Repeatable region in Album template holds order numbers for each song. Conditionally repeatable is hidden if nothing is related.
Solution 2 - better -
Mosaic tile in Album holds a simple relation to Songs plus a text editable with song's order.
I decided to make an addon to solve this problem. KK, reading the code I noticed you were going to add some kind of function to sort the items based on their weight

I did it in a hurry so it's not a clean approach and it can be improved a lot. Although I tested it and can't find bugs yet. I need to test it further. But it's a start.

The addon allows the user to order the list by dragging the items. In the admin panel it is always rendered based on weight. Using the orderby parameter of the related_pages tag will override the order, but not in the admin panel. It only works when advanced_gui is disabled.

Installation is no different than any other addon.

Hopefully you guys can test it and review the code. Please test it in a clean installation just to be safe.

Image

Attachments

6 posts Page 1 of 1
cron