This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

styr112
styr112

Hey everyone,

I'm trying to develop a very simple plugin with some relations. I have Artists and Bands. Bands can have one or more artists. On the backend is everything working and on the DB too.

So I have 3 tables:

  • styr_arquivo_bands_artists
  • styr_arquivo_bands
  • styr_arquivo_artists

and styr_arquivo_bands_artists just have 3 columns: id, artists_id and bands_id

Now, on the front end, when I access the Band detail page, I want to print the band members. How can I do it ?

Thanks.

JeffGoldblum
JeffGoldblum

You can try doing something like this:

{% for artist in band.artists %}
    {{ artist.name }}
    {{ artist.otherInfo }}
{% endfor %}
styr112
styr112

LukeTowers said:

You can try doing something like this:

{% for artist in band.artists %}
   {{ artist.name }}
   {{ artist.otherInfo }}
{% endfor %}

Thanks for your quick answer Luke, but I think is something missing before that. I think I should call some component or something like that before add that to the .htm

JeffGoldblum
JeffGoldblum

So how are you currently displaying information about the Band on the band details page?

styr112
styr112

With the builder component.

Basically I just need to know how to display the info without the help of Builder component.

JeffGoldblum
JeffGoldblum

If you don't want to use the builder component, then you will have to write your own component to get the data from the database and pass it to the theme

1-6 of 6

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.