Could you use MIGX to create a CMP for editing chunks?

Full disclosure, I’m normally more of a front-end dev, so bear with me if this is a stupid question :neutral_face:

Usecase
I’ve got a client that is running a multi-domain site on modx 2.71. Each domain represents a single, independent event, but often the same speakers are at multiple events year after year. Some speakers are added to several different pages for various lengths of time.

Right now, we’re putting the speakers info in a chunk. However, the client isn’t capable of doing the changes themselves (They really suck at coding. Like really.), so it’s left to me. But the changes are so frequent (sometimes hourly) and so maddeningly vague (“hey, we just got a new speaker, can you pls add them ASAP? thx!!!”) I need to hand the updating back to them.

They do understand chunks though, and since we often use them on several pages (like main session, workshops, featured speakers, etc) keeping the data in a chunk would be ideal.

Question:
My thought was to create a CMP with MIGX and point it to site_htmlsnippets and add a couple new columns to handle the data. I can easily create the forms and use migX to display only chunks from a certain folder, and the client can use the CMP to edit the content with an editor.

BUT this is where my understanding falls off. How can I get the data to display when the chunk is called? Obviously I can’t just build the tpl into the chunk, since the placeholders would come from the resource, not the chunk itself. So I’m thinking it would either be something in MigX, or a snippet, or maybe something with property sets? Does anyone have an suggestions on the best direction to go here?

not sure, to understand your problem.
no problem so far: you are trying to create a CMP, where your client can add and edit some chunks
your issue: you are trying to add some resource - specific infos, while editing the chunk?

could you show some code, how you are adding your speakers to events currently, to have a better picture of what you are trying to solve?

I would suggest putting all of the speakers, their info bio etc, into a custom database table.

Then create a multiselect TV [[*speakers]] using an @SELECT binding to fetch the list of speakers where they can just select the featured speakers for the event(context).
https://docs.modx.org/current/en/building-sites/elements/template-variables/bindings/select-binding

Pass the value of this TV into a snippet that fetches the related data from the database.

[[fetchSpeakers? &speakers=`[[*speakers]]`]]

Then in the snippet you’ll need to handle getting the data from the table and then returning it into a chunk
https://docs.modx.org/current/en/extending-modx/snippets

that was my thinking, too. You could use migxLoopCollection to fetch the speakers. No need to invent a new snippet

1 Like

but the help could be more specific, if we would see some code

My xml schema and an example tpl are below. Thanks for your help! I was hoping Bruno would see this :smile:

<model package="speakers" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
<object class="Speaker" table="site_htmlsnippets" extends="xPDOSimpleObject">

<field key="id" dbtype="int" precision="255" phptype="integer" null="false" default=""/>
<field key="source" dbtype="int" precision="255" phptype="integer" null="false" default=""/>
<field key="property_preprocess" dbtype="tinyint" precision="255" phptype="integer" null="false" default="0"/>
<field key="name" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="presenter_name" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="presenter_title" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="presenter_company" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="presenter_bio" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="description" dbtype="varchar" precision="100" phptype="string" null="false" default=""/>
<field key="editor_type" dbtype="int" precision="100" phptype="integer" null="false" default="0"/>
<field key="category" dbtype="int" precision="100" phptype="integer" null="false" default="0"/>
<field key="cache_type" dbtype="tinyint" precision="255" phptype="integer" null="false" default="0"/>
<field key="snippet" dbtype="mediumtext" precision="255" phptype="string" null="false" default=""/>
<field key="locked" dbtype="tinyint" precision="255" phptype="integer" null="false" default="0"/>
<field key="properties" dbtype="varchar" precision="100" phptype="string" null="false" default=""/>
<field key="static" dbtype="tinyint" precision="255" phptype="integer" null="false" default="0"/>
<field key="static_file" dbtype="string" precision="255" phptype="string" null="false" default="0"/>
</object>
</model>



<h1> [[+presenter_name]]</h1> 
<h2> [[+presenter_title]],[[+presenter_company]]</h2> 
<p>  [[+presenter_bio]]</p>

Thanks! This is an interesting idea, but I’d prefer to keep it to chunks rather than tvs. We use a lot of different templates and make new ones all the time. I know to us it sounds simple, but the client has a hard time finding/remembering where tvs are unless I do a form customization to put it on modx-resource-settings. With a chunk, I wouldn’t have to worry about whether the tv was assigned to that template and where the tv was showing on update/create resource.

Good, I can see, you have a db-schema with a table for the speakers (with some mistakes in the field-definitions, how it seems to me)
and a tpl-chunk for listing the speakers.
Do you also have a working CMP to add and edit new speakers?

Still not sure, to understand, where you get stuck. Could you try to explain (with some code examples), again?

The question reminded me of an old extra by the legendary Romain: Asides. From what I remember, that’s actually chunks you can associate with pages and it’s editable from the manager page. Might be just what you need*.

(*Or I misremembered what it did.)