PHP code example of se7enxweb / explayouts-core

1. Go to this page and download the library: Download se7enxweb/explayouts-core library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

se7enxweb / explayouts-core example snippets



$layoutService = new expLayoutsCoreLayoutService();
$blockService  = new expLayoutsCoreBlockService();
$zoneService   = new expLayoutsCoreZoneService();

$layout = $layoutService->create( 'homepage', 'Homepage', '2_column' );
$zones  = $zoneService->loadByLayout( $layout->attribute( 'id' ), 1 );

$block = $blockService->create( $zones[0]->attribute( 'id' ),
                                $layout->attribute( 'id' ),
                                'text', 'Intro', 'default' );
$blockService->setParameters( $block->attribute( 'id' ),
                              array( 'content' => '<p>Hello</p>' ) );

$layoutService->publish( $layout->attribute( 'id' ) );


$ruleService = new expLayoutsCoreRuleService();
$rule = $ruleService->create( $layoutId, 10, 1 ); // priority 10, enabled
$ruleService->setTargets( $ruleId, array( array( 'type' => 'subtree', 'value' => '2' ) ) );
$ruleService->setConditions( $ruleId, array( array( 'type' => 'siteaccess', 'value' => 'site' ) ) );