Advanced catalogue back-refs

Post

Posted
Rating:
Item has a rating of 5 Item has a rating of 5 Item has a rating of 5 Item has a rating of 5 Item has a rating of 5 (Liked by Adam Edington)
#5308 (In Topic #1071)
Hi,

This is to help out @KingBast who likes to do over-complicated stuff with catalogues :P . It follows on from an IRC conversation.

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'.

Post

Posted
Rating:
#5478
In the next release a little bug which returned too many results was fixed. Also you don't need to do any database dipping as the ID's will be shown next to the fields when editing a catalogue. This is really useful, especially the ID's ;) Thanks Chris.
1 guest and 0 members have recently viewed this.