Issue Feature Closed

#44345backend_layout: customized width for columns

Uwe Jakobs 01/06/13, 19:11 updated 10/24/17, 20:20

Description

Some editors wanted me to assimilate the columns width in the Backend with the output in Frontend. Since I am using “Backend Layouts” (Grid View), all columns are displayed with an equal width. The backend-Layout is rendered in the class typo3/sysext/backend/Classes/View/PageLayoutView.php, so I had to fiddle around here a little bit.

My small solution could be interesting for the community, so here it is:

in PageLayoutView.php replace lines 534 – 542

    // Add colgroups
    $colCount = intval($parser->setup['backend_layout.']['colCount']);
    $rowCount = intval($parser->setup['backend_layout.']['rowCount']);

    $grid .= '<colgroup>';
        for ($i = 0; $i < $colCount; $i++) {
            $grid .= '<col style="width:' . (100 / $colCount) . '%"></col>';
    }
    $grid .= '</colgroup>';

with these lines:

    // Add colgroups
    $colCount = intval($parser->setup['backend_layout.']['colCount']);
    $rowCount = intval($parser->setup['backend_layout.']['rowCount']);
    $colRatio = $parser->setup['backend_layout.']['colRatio'];

    $grid .= '<colgroup>';
    if ($colRatio){
        $splitRatioArr = explode('|',$colRatio);
        foreach ($splitRatioArr as $colWidth) {
            $grid .= '<col style="width:' . $colWidth . '%"></col>';
        }
    } else {
        for ($i = 0; $i < $colCount; $i++) {
            $grid .= '<col style="width:' . (100 / $colCount) . '%"></col>';
        }
    }
    $grid .= '</colgroup>';

This little exercise gives you the possibility to add a new Element to the backend_layout-Array: it is called colRatio and contains width-ratio in percentages (devided by the Pipe-Symbol |):

backend_layout {
    colCount = 2
    *colRatio = 80|20*
    rowCount = 3
    rows {
        1 {
            columns {
                1 {
                    name = Banner 1
                    colPos = 8
                }
                2 {
                    name = Banner 2
                    rowspan = 3
                    colPos = 9
                }
            }
        }
        2 {
            columns {
                1 {
                    name = Header
                    colPos = 3
                }
            }
        }
        3 {
            columns {
                1 {
                    name = Content
                    colPos = 0
                }
            }
        }
    }
}

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.