Hi, first and foremost, the MIGX plugin is great!
I have a few questions regarding "how-to" do a few things.
First:
I have a checkbox on the frontend form submission, where a user can check a box to say whether they're a staff member or not - in the database this is represented as 1/0. In my MIGX form tab, I have the appropriate column name (is_staff) as a listbox, with the "Input Options Values" as "Yes==1||No==0", but this is always represented as "Yes" even if the database value is 0. How can I ensure the correct database value is represented in this listbox?
Second:
I have an images table, which contains three versions of the image (orig, large, small). Currently this is a listbox in MIGX, with "Input Options Values" as
@EVAL return 'select one==||' . $modx->runSnippet('migxLoopCollection',array('packageName'=>'ideas','classname'=>'Images','tpl'=>'@CODE:[[+orig]]==[[+id]]','outputSeparator'=>'||'));
This works well, but it displays the URL value of orig, rather than the actual image. How would I get this listbox to render images instead of the URL of the image?
Third:
I have a couple of relationship tables, for example each idea can be tagged up to three times.
My classes are like:
Tags
- name
TagsRel
- idea_id
- tag_id
How would I display a multi-select displaying each Tags name field, but the value updated in TagsRel with the current idea_id? I'd also like to note that the Idea table doesn't "know" about the TagsRel/Tags tables - so whether this needs to be amended or not would be good to know.
Fourth:
"EditedOn" currently displays the ID of the user, rather than the username. I know I've read about this somewhere before, but I cannot find the resource again.
Fifth:
I have a request to color-code rows in the CMP based on the value of a column. For example, if "published" was 0, the row would become a reddish color, or if published was 1 the row would become green. Basically an easy way of seeing what needs attention. How would I achieve something like this?
Apologies that this post is rather long and contains many questions - I have been saving them up!
My (edited down) MySQL Schema is below for reference:
<?xml version="1.0" encoding="UTF-8"?>
<model package="ideas" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
<object class="Ideas" table="c_ideas" extends="xPDOSimpleObject">
<field key="is_staff" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0"/>
<field key="image" dbtype="int" precision="11" attributes="unsigned" phptype="integer" null="true" default="0"/>
<field key="createdon" dbtype="datetime" phptype="datetime" null="true"/>
<field key="editedon" dbtype="datetime" phptype="datetime" null="true"/>
<field key="editedby" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0" />
<field key="deleted" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" />
<field key="published" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" />
<aggregate alias="EditedBy" class="modUser" local="editedby" foreign="id" cardinality="one" owner="foreign"/>
<aggregate alias="" class="Images" local="image" foreign="id" cardinality="one" owner="foreign"/>
</object>
<object class="Tags" table="c_tags" extends="xPDOSimpleObject">
<field key="name" dbtype="varchar" precision="32" phptype="string" null="false" default=""/>
</object>
<object class="Status" table="c_status" extends="xPDOSimpleObject">
<field key="name" dbtype="varchar" precision="32" phptype="string" null="false" default=""/>
<field key="class" dbtype="varchar" precision="32" phptype="string" null="false" default=""/>
</object>
<object class="Votes" table="c_votes" extends="xPDOSimpleObject">
<field key="idea_id" dbtype="int" precision="11" phptype="integer" attributes="unsigned" null="false" default="0"/>
<field key="fbid" dbtype="varchar" precision="32" phptype="string" null="true" default=""/>
<field key="ip_address" dbtype="varchar" precision="50" phptype="string" null="true" default=""/>
<field key="value" dbtype="int" precision="3" phptype="integer" attributes="" null="true" default="0"/>
<field key="useragent" dbtype="varchar" precision="1024" phptype="string" null="true" default=""/>
<field key="timestamp" dbtype="datetime" phptype="datetime" null="true"/>
<aggregate alias="" class="Ideas" local="idea_id" foreign="id" cardinality="many" owner="foreign"/>
</object>
<object class="TagsRel" table="c_tags_rel" extends="xPDOSimpleObject">
<field key="idea_id" dbtype="int" precision="11" phptype="integer" null="false" default="0"/>
<field key="tag_id" dbtype="int" precision="11" phptype="integer" null="false" default="0"/>
<aggregate alias="" class="Ideas" local="idea_id" foreign="id" cardinality="many" owner="foreign"/>
<aggregate alias="" class="Tags" local="tag_id" foreign="id" cardinality="many" owner="foreign"/>
</object>
<object class="StatusRel" table="c_status_rel" extends="xPDOSimpleObject">
<field key="idea_id" dbtype="int" precision="11" phptype="integer" null="false" default="0"/>
<field key="status_id" dbtype="int" precision="11" phptype="integer" null="false" default="0"/>
<field key="timestamp" dbtype="datetime" phptype="datetime" null="true"/>
<aggregate alias="" class="Ideas" local="idea_id" foreign="id" cardinality="many" owner="foreign"/>
<aggregate alias="" class="Status" local="status_id" foreign="id" cardinality="many" owner="foreign"/>
</object>
<object class="Images" table="c_images" extends="xPDOSimpleObject">
<field key="large" dbtype="varchar" precision="256" phptype="string" null="true" default="" />
<field key="small" dbtype="varchar" precision="256" phptype="string" null="true" default="" />
<field key="orig" dbtype="varchar" precision="256" phptype="string" null="true" default="" />
<field key="featured" dbtype="tinyint" precision="1" phptype="integer" attributes="unsigned" null="false" default="0"/>
<field key="timestamp" dbtype="datetime" phptype="datetime" null="true"/>
</object>
</model>
[ed. note: ahrenks last edited this post 13 years, 1 month ago.]