Advanced catalogue back-refs
Posted
#5741
(In Topic #1341)

Site director

This is to help out @KingBast who likes to do over-complicated stuff with catalogues

As I understand it, his use case is he has 3 catalogues. Let's make this abstract and call them a, b, c.
Catalogue 'a' has entries in it that fields in catalogues 'b' and 'c' are referencing (via "A reference to a catalogue entry in a catalogue" fields).
He wants it so that when you view catalogue 'a' entries you get links to the referencing entries in catalogue 'b' only.
Currently it is not possible, because the CATALOGUE_ENTRY_BACKREFS symbol is going to find back-references from all fields pointing to entries in 'a', there's no way to filter it down to individual fields.
I have fixed this in https://github.com/ocproducts/composr/commit/8951633e96c9579e35868a837ddde93df361c2a0, which will be in the next patch release. Now you can filter your back-refs to only ones appearing in a particular field.
You need to dip into the database to find the field IDs. In my test site my catalogue 'b' reference field is #45, so that's what I'll use.
If I make CATALOGUE_a_ENTRY_SCREEN.tpl, to override how entries in catalogue 'a' are templated, I can include this code:
Code
{+START,LOOP,{$CATALOGUE_ENTRY_BACKREFS,{ID},,,,45}}
<a href="{$PAGE_LINK*,site:catalogues:entry:{_loop_var}}">{$CATALOGUE_ENTRY_FIELD_VALUE*,{_loop_var},0}</a>
{+END}
This works. It generates hyperlinks, with proper captions, pointing back to the entries in catalogue 'b'.
Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon
- If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
- If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
- If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
- If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Posted

Site staff


1 guest and 0 members have just viewed this.