Front-end related select

Hello,

I would like to know if it is possible to reproduce a “related” field on the front-end to allow members to select news related to a subject.

To display data in a form with a multiple select.

Thanks for your leads.

Michael

You mean use the pages field in the frontend? No, that’s not possible. The Panel fields all rely on Vue.js and a lot of logic, you cannot reproduce this in your frontend.

Thanks.

Maybe if I use another type of field in my blueprint, it will work.

I will try with a select.

I test differently with a multiselect (it’s the same principle).

                  social_events_listing2_select:
                    label: Lien vers page(s)
                    type: multiselect
                    options:
                      type: query
                      query: site.find('sejours', 'sorties/recits/dominical', 'sorties/recits/mercredi', 'sorties/recits/jour-ferie',  'actualites').children.published
                      #text: "{{ page.title }}"
                      # value: "{{ page.slug }}"

I see the selection of pages with a dump (which I did in the panel).

Now I need to be able to display the list in the front-end, to be able to select it.

It’s doable ?

With a multiple-choice select, that should do it.
https://preview.colorlib.com/theme/bootstrap/multiselect-05/

Thanks

$selectedPages = $page->social_events_listing2_select()->toPages(',');

Don’t know why you are using a multi-select instead of a pages field?

Hi,

I did this:

<?php 
  $selectedPages = $listing->social_events_listing2_select()->toPages(',');
  foreach($selectedPages as $selectedPage):

    dump($selectedPage);
?>

Here is the result :

When a page is already selected (‘sorties/stories/dominical’) I have the possibility of recovering the other pages (siblings).

If no page is selected, I have nothing.

How do I get to the list of pages in the blueprint Query?

Use the same query in PHP.

$options = $site->find('sejours', 'sorties/recits/dominical', 'sorties/recits/mercredi', 'sorties/recits/jour-ferie',  'actualites')->children()->published();