Here's another extended MM Forum field. (Maybe someone can use it as a
reference?)

This one displays a series of checkboxes, with data from the
fe_groups, so that the FE user can select the FE group he/she wants to
be a member of.

-- cut --
label = TEXT
label {
        value = Temagrupper
}
input = COA
input {
        // Save current value in register
        10 = LOAD_REGISTER
        10.fieldvalue.field = fieldvalue

        // Create hidden input boxes for existing non-themagroups
        20 = TEXT
        // Default usergroup for new users = 58
        // We need to set this here, as save will override the default
group set in MM forum
        20.value = 58
        // But if a value already exists, use that instead. (Existing
users)
        20.override.field = fieldvalue
        20.split {
                token = ,
                cObjNum = 1
                1 {
                        10 = CONTENT
                        10 {
                                table = fe_groups
                                select {
                                        pidInList = 1351
                                        andWhere.dataWrap =
uid={current:1} AND tx_sbnregional_istheme=0
                                }
                                renderObj = TEXT
                                renderObj.dataWrap = <input
type="hidden" name="###USERFIELD_NAME###[]" value="{field:uid}" />
                        }
                }
        }

        30 = CONTENT
        30 {
                table = fe_groups
                select {
                        pidInList = 1351
                        where = tx_sbnregional_istheme=1
                        orderBy = title
                }
                renderObj = TEXT
                renderObj {
                        insertData = 1
                        value = <input type="checkbox"
name="###USERFIELD_NAME###[]" value="{field:uid}" /> {field:title}<br
/>
                        override = <input type="checkbox"
name="###USERFIELD_NAME###[]" value="{field:uid}" checked="checked" />
{field:title}<br />
                        override.if.value.data = register:fieldvalue
                        override.if.isInList.field = uid
                }
        }
}
output = COA
output {
        10 = TEXT
        10.field = fieldvalue
        10.wrap = <ul>|</ul>
        10.required = 1
        10.split {
                token = ,
                cObjNum = 1
                1 {
                        10 = CONTENT
                        10 {
                                table = fe_groups
                                select {
                                        pidInList = 1351
                                        andWhere.dataWrap =
uid={current:1} AND tx_sbnregional_istheme=1
                                        orderBy = title
                                }
                                renderObj = TEXT
                                renderObj.field = title
                                renderObj.wrap = <li>|</li>
                        }
                }
        }
}
datasource = usergroup

-- cut --

Unfortunatly MM Forum doesn't support saving of multiple checkboxes,
so you'll have to patch the source.

In line 352 of the file "class.tx_mmforum_pi2.php", insert this:

-- cut --
                // Add support for multiselect checkboxes
                if (is_array($value)) $value = implode(',',$value);
-- cut --

--
Peter Klein


On Thu, 20 Aug 2009 09:33:20 +0200, Peter Klein <[email protected]>
wrote:

>Hi Sean.
>
>I did it like this: 
>
>-- cut --
>label = TEXT
>label {
>       value = Kommune / Organisation
>}
>input = COA
>input {
>       // Save current value in register
>       5 = LOAD_REGISTER
>       5.fieldvalue.field = fieldvalue
>
>       wrap = <select
>name="###USERFIELD_NAME###">|</optgroup></select>
>       10 = CONTENT
>       10 {
>               table = tx_sbnregional_municipal
>               select {
>                       pidInList = 1351
>                       where = 1=1
>                       orderBy = region,title
>               }
>               renderObj = COA
>               renderObj {
>                       10 = CONTENT
>                       10 {
>                               table = tx_sbnregional_region
>                               select {
>                                       pidInList = 1351
>                                       andWhere.dataWrap =
>uid={field:region}
>                               }
>                               renderObj = TEXT
>                               renderObj {
>                                       value = <optgroup
>label="{field:title}">
>                                       insertData = 1
>                                       override =
></optgroup><optgroup label="{field:title}">
>                                       override.if.isTrue.data =
>register:region
>                               }
>                               stdWrap.if {
>                                       value.field = region
>                                       equals.data = register:region
>                                       negate = 1
>                               }
>                       }
>                       
>                       20 = COA
>                       20 {                            
>                               10 = TEXT
>                               10.dataWrap = <option
>value="{field:uid}" label="{field:title}"
>selected="selected">{field:title}</option>
>                               10.if.value.data = register:fieldvalue
>                               10.if.equals.field = uid
>
>                               20 < .10
>                               20.dataWrap = <option
>value="{field:uid}" label="{field:title}">{field:title}</option>
>                               20.if.negate = 1
>                       }
>                       
>                       30 = LOAD_REGISTER
>                       30.region.field = region
>
>               }
>       }
>}
>output = COA
>output {
>       10 = CONTENT
>       10 {
>               table = tx_sbnregional_municipal
>               select {
>                       pidInList = 1351
>                       andWhere.dataWrap = uid={field:fieldvalue}
>                       orderBy = title
>               }
>               renderObj = TEXT
>               renderObj.field = title
>       }
>}
>datasource = tx_sbnregional_kom_org
>-- cut --
>
>It's a bit more advanced than your snippet, as it fills the selectbox
>with data from 2 DB tables (OPTGROUP data comes from table1, and
>OPTION data from table2)
>
>The current selected item is stored in the LOAD_REGISTER part, and
>then reused in various places of the script.
_______________________________________________
TYPO3-english mailing list
[email protected]
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-english

Reply via email to