src/Application.php
public function main()
    {
        $mainPageHTML = '';
        $dbMaterials = array();

        // Получим все материалы
        if (
        dbQuery('samsoncms\api\Material')
            ->join('user')
            ->cond('Active', 1)
            ->cond('Draft', 0)
            ->order_by('Created', 'DESC')
            ->cond('Name', "", dbRelation::NOT_EQUAL)
            ->limit(5)
            ->exec($dbMaterials)
        ) {
            // Render material rows
            $rowsHTML = '';
            foreach ($dbMaterials as $dbMaterial) {
                $rowsHTML .= $this->view('main/row')
                    ->set($dbMaterial, 'material')
                    ->set(isset($dbMaterial->onetoone['_user']) ? $dbMaterial->onetoone['_user'] : array(), 'user')
                    ->output();
            }

            for ($i = sizeof($dbMaterials); $i < 5; $i++) {
                $rowsHTML .= $this->view('main/row')->output();
            }

            // Render main template
            $mainPageHTML = $this->view('main/index')->set($rowsHTML, 'rows')->output();
        }

        // Return material block HTML on main page
        return $mainPageHTML;
    }
public function main()
    {
        $mainPageHTML = '';
        $dbMaterials = array();

        // Получим все материалы
        if (
        dbQuery('samsoncms\api\Material')
            ->join('user')
            ->cond('Active', 1)
            ->cond('Draft', 0)
            ->order_by('Created', 'DESC')
            ->cond('Name', "", dbRelation::NOT_EQUAL)
            ->limit(5)
            ->exec($dbMaterials)
        ) {
            // Render material rows
            $rowsHTML = '';
            foreach ($dbMaterials as $dbMaterial) {
                $rowsHTML .= $this->view('main/row')
                    ->set($dbMaterial, 'material')
                    ->set(isset($dbMaterial->onetoone['_user']) ? $dbMaterial->onetoone['_user'] : array(), 'user')
                    ->output();
            }

            for ($i = sizeof($dbMaterials); $i < 5; $i++) {
                $rowsHTML .= $this->view('main/row')->output();
            }

            // Render main template
            $mainPageHTML = $this->view('main/index')->set($rowsHTML, 'rows')->output();
        }

        // Return material block HTML on main page
        return $mainPageHTML;
    }
public function main ( ) { $ mainPageHTML = '' ; $ dbMaterials = array ( ) ; // Получим все материалы if ( dbQuery ( 'samsoncms\api\Material' ) -> join ( 'user' ) -> cond ( 'Active' , 1 ) -> cond ( 'Draft' , 0 ) -> order_by ( 'Created' , 'DESC' ) -> cond ( 'Name' , "" , dbRelation :: NOT_EQUAL ) -> limit ( 5 ) -> exec ( $ dbMaterials ) ) { // Render material rows $ rowsHTML = '' ; foreach ( $ dbMaterials as $ dbMaterial ) { $ rowsHTML .= $ this -> view ( 'main/row' ) -> set ( $ dbMaterial , 'material' ) -> set ( isset ( $ dbMaterial -> onetoone [ '_user' ] ) ? $ dbMaterial -> onetoone [ '_user' ] : array ( ) , 'user' ) -> output ( ) ; } for ( $ i = sizeof ( $ dbMaterials ) ; $ i < 5 ; $ i ++ ) { $ rowsHTML .= $ this -> view ( 'main/row' ) -> output ( ) ; } // Render main template $ mainPageHTML = $ this -> view ( 'main/index' ) -> set ( $ rowsHTML , 'rows' ) -> output ( ) ; } // Return material block HTML on main page return $ mainPageHTML ; }
Output for main page
Output for main page