Builder Plugin Set Identifier Value Through Partial

- 1 answer

I am trying to use output data that I have set up using the builder plugin through the Record Details component and running into some issues.

In my created plugin, Schools, I have Instructors (set up as a relation to an instructors plugin I created separately). It is possible to have more than one instructor, so they are store in the database as an array. Like so:


The numbers represent the row ID of the instructor table

In my CMS I can pull all of the School info just fine into a partial (Builder Details), and can pull the array of instructors, but I am struggling to pass this array over to look up the ID and get the instructors information. My thought right now is to send it to another partial like so:

{% "school/instructor" insProfile = instructorID %}

The partial school/instructor is getting the ID just fine. I have included the Builder Details component and set it up with the following:

Alias: builderDetails
ModelClass: Instructors Plugin
Identifier value: insProfile 
Key Column: id 
Display Column: member_name

I am getting record not found results. I am confused as to how to set the Identifier Value to match the value I passed through my partial. I tried {% set identifierValue = insProfile %} before the {% set record = ... %} is run, but that did not work either.

I cannot use the :slug because that is already generating the content needed for the School page. In a TLDR, it seems I ultimately want to duplicate this function through another partial and a different tag.

Still learning October, so any help is appreciated.



I think the original post was a bit lengthy and ultimately what I wanted to do was pass a variable into a component. Such as:

{% component 'builderDetails' identifierValue=dynamicVar %}

This does not appear to work as the builder details component generates too far into page load to pick up the variable change.

Per the OctoberCMS docs, the best solution for me was to create my own component that would accept the variable before the page processed using onRender() function.

    public function onRender()
    // This code will be executed before the default component
    // markup is rendered on the page or layout.
    $this->profileID = $this->property('insProfile');
    $this->ins = $this->getUserInfo($this->profileID);

This allows me to put my component in a partial, and request the partial with the variable 'insProfile'. The component will pick up the property insProfile before page/plugin generates and use that variable instead of the default.

I then set up another function to query the correct user info needed (getUserInfo)

It would be nice if the builder plugin components could be updated in such a way that I did not have to do this as the builder plugin is rather extensive out of the box.

Posting this in case anyone else comes along this problem and isn't sure where/how to pass a partial variable into a component.