PHP code example of se7enxweb / expsite-api

1. Go to this page and download the library: Download se7enxweb/expsite-api 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 / expsite-api example snippets


$query = array(
    'parent_id' => 2,
    'content_type_identifier' => array( 'article' ),
    'limit' => 10,
    'offset' => 0,
    'sort_by' => array( 'published', false ),
    'depth' => 2, // only for location queries
);

$content  = expSiteApi::content()->load( 42 );
$location = expSiteApi::location()->load( 2 );
$children = expSiteApi::location()->loadChildren( 2, array( 'limit' => 10 ) );
$items    = expSiteApi::filter()->findContent( array(
    'parent_id' => 2,
    'content_type_identifier' => array( 'article' ),
) );

$content = expSiteApi::content()->load( 42 );                    // by content object ID
$content = expSiteApi::content()->loadByRemoteId( 'abc123' );    // by remote ID
$content = expSiteApi::content()->loadByLocationId( 60 );        // content shown at a node

$location = expSiteApi::location()->load( 2 );               // by node ID
$location = expSiteApi::location()->loadByContentId( 42 );   // main node of a content object
$parent   = expSiteApi::location()->loadParent( 60 );        // parent node

$articles = expSiteApi::filter()->findContent( array(
    'parent_id' => 2,
    'content_type_identifier' => array( 'article' ),
    'limit' => 10,
    'offset' => 0,
    'sort_by' => array( 'published', false ),
) );

$nodes = expSiteApi::filter()->findLocations( array(
    'parent_id' => 2,
    'depth' => 2,
    'content_type_identifier' => array( 'folder' ),
) );

$items = expSiteApi::filter()->findLocations( array( 'parent_id' => $parentId, 'limit' => 20 ) );

$payload = array_map(
    function( $location ) { return $location->toArray(); },
    $items
);

header( 'Content-Type: application/json' );
echo json_encode( array( 'items' => $payload ) );