3 users online. Create an account or sign in to join them.Users

Search

I’m grouping the data source output of a section by checkbox values (so there are two possible groups: yes and no). There are three entries, only one with an inactive checkbox. For some reasons I get this output

<auswahl value="no">
    <entry id="598">
        <block-1>
            <item id="536" handle="vl-31040-boehringer-anfang-der-kunst" section-handle="veranstaltungen" section-name="Veranstaltungen">VL 31040 / Böhringer: Anfang der Kunst</item>
        </block-1>
        <block-2>
            <item id="499" handle="se-31003-becker-atmosphaeren-durchdringung-von-zeichen-und-leben" section-handle="veranstaltungen" section-name="Veranstaltungen">SE 31003 / Becker: Atmosphären: Durchdringung von Zeichen und Leben</item>
        </block-2>
        <block-3>
            <item id="537" handle="ue-31041-boehringer-ende-der-kunst" section-handle="veranstaltungen" section-name="Veranstaltungen">UE 31041 / Böhringer: Ende der Kunst</item>
        </block-3>
        <modul>
            <item handle="m5-b08">M5/B08</item>
        </modul>
    </entry>
    <entry id="599">
        <block-1>
            <item id="0" handle="" />
        </block-1>
        <block-2>
            <item id="519" handle="se-31023-moenninger-bahn-frei-neue-raumtheorien" section-handle="veranstaltungen" section-name="Veranstaltungen">SE 31023 / Mönninger: Bahn frei: Neue Raumtheorien</item>
        </block-2>
        <block-3>
            <item id="0" handle="" />
        </block-3>
        <modul>
            <item handle="m5-b08">M5/B08</item>
        </modul>
    </entry>
    <entry id="600">
        <block-1>
            <item id="0" handle="" />
        </block-1>
        <block-2>
            <item id="535" handle="se-31039-zerbst-die-kunstakademie-geschichte-und-gegenwart" section-handle="veranstaltungen" section-name="Veranstaltungen">SE 31039 / Zerbst: Die Kunstakademie. Geschichte und Gegenwart</item>
        </block-2>
        <block-3>
            <item id="0" handle="" />
        </block-3>
        <modul>
            <item handle="m5-b08">M5/B08</item>
        </modul>
    </entry>
</auswahl>

which groups all three entries under the value no while I would expect this:

<auswahl value="no">
    <entry id="598">
        <block-1>
            <item id="536" handle="vl-31040-boehringer-anfang-der-kunst" section-handle="veranstaltungen" section-name="Veranstaltungen">VL 31040 / Böhringer: Anfang der Kunst</item>
        </block-1>
        <block-2>
            <item id="499" handle="se-31003-becker-atmosphaeren-durchdringung-von-zeichen-und-leben" section-handle="veranstaltungen" section-name="Veranstaltungen">SE 31003 / Becker: Atmosphären: Durchdringung von Zeichen und Leben</item>
        </block-2>
        <block-3>
            <item id="537" handle="ue-31041-boehringer-ende-der-kunst" section-handle="veranstaltungen" section-name="Veranstaltungen">UE 31041 / Böhringer: Ende der Kunst</item>
        </block-3>
        <modul>
            <item handle="m5-b08">M5/B08</item>
        </modul>
    </entry>
</auswahl>
<auswahl value="yes">
    <entry id="599">
        <block-1>
            <item id="0" handle="" />
        </block-1>
        <block-2>
            <item id="519" handle="se-31023-moenninger-bahn-frei-neue-raumtheorien" section-handle="veranstaltungen" section-name="Veranstaltungen">SE 31023 / Mönninger: Bahn frei: Neue Raumtheorien</item>
        </block-2>
        <block-3>
            <item id="0" handle="" />
        </block-3>
        <modul>
            <item handle="m5-b08">M5/B08</item>
        </modul>
    </entry>
    <entry id="600">
        <block-1>
            <item id="0" handle="" />
        </block-1>
        <block-2>
            <item id="535" handle="se-31039-zerbst-die-kunstakademie-geschichte-und-gegenwart" section-handle="veranstaltungen" section-name="Veranstaltungen">SE 31039 / Zerbst: Die Kunstakademie. Geschichte und Gegenwart</item>
        </block-2>
        <block-3>
            <item id="0" handle="" />
        </block-3>
        <modul>
            <item handle="m5-b08">M5/B08</item>
        </modul>
    </entry>
</auswahl>

Am I doing something wrong? Is this a bug or a field limitation?

Okay, this seems to be a bug. There is an undefined variable $handle used in the field’s groupRecords function which breaks things. Changing $handle to $value fixes the issue:

function groupRecords($records){

    if(!is_array($records) || empty($records)) return;

    $groups = array($this->get('element_name') => array());

    foreach($records as $r){
        $data = $r->getData($this->get('id'));

        $value = $data['value'];

        if(!isset($groups[$this->get('element_name')][$value])){
            $groups[$this->get('element_name')][$value] = array(
                'attr' => array(
                    'value' => $value
                ),
                'records' => array(), 
                'groups' => array()
            );
        }   

        $groups[$this->get('element_name')][$value]['records'][] = $r;

    }

    return $groups;
}       

Checkbox values don’t have handles??? I thought that everything in Symphony has one.

But you are right. (I checked the database.) There’s only a value.

Could you post this on the bug tracker?

Sorry, you were even faster than I expected.

I just noticed that this has only partly been fixed in the current Symphony codebase. These lines

if(!isset($groups[$this->get('element_name')][$handle])){
    $groups[$this->get('element_name')][$handle] = array('attr' => array('value' => $value),
                                                         'records' => array(), 'groups' => array());
}

should be

if(!isset($groups[$this->get('element_name')][$value])){
    $groups[$this->get('element_name')][$value] = array(
        'attr' => array(
            'value' => $value
        ),
        'records' => array(), 
        'groups' => array()
    );
} 

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.2 or above
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.0 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details