PHP code example of ontariotechu / xmodule
1. Go to this page and download the library: Download ontariotechu/xmodule 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/ */
ontariotechu / xmodule example snippets
use \XModule\Base\XModule;
use \XModule\Shared\Link;
use \XModule\Constants\LinkType;
use \XModule\ButtonContainer;
use \XModule\LinkButton;
/**
* Create a new XModule
*/
$xmodule = new XModule();
/**
* Create XModule elements
*/
$buttonContainer = new ButtonContainer(['id' => 'link_buttons']);
$link = new Link('./', LinkType::RELATIVE_PATH);
$button = new LinkButton('Click here', ['link' => $link]);
/**
* Attach your elements to each other and the XModule
*/
$buttonContainer->addButton($button)
$xmodule->addContent($buttonContainer);
/**
* Render the output
*/
echo json_encode($xmodule->render());