1. Go to this page and download the library: Download dartanian300/xmodule-php 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/ */
dartanian300 / xmodule-php example snippets
// Create root response element
$response = new XModuleResponse();
// Create content elements
$container = new ButtonContainer();
$button = new LinkButton();
$button->title->set("Click Me");
$container->add($button);
// Add elements to root response element
$response->add($container);
// Print JSON response
echo json_encode($response);
$collapsible = new Collapsible();
$collapsible->disclosureIcon->plusminus();
$collapsible->disclosureIcon->get();
$collapsible = new Collapsible();
$collapsible->title->set("I'm a collapsible title!");
$collapsible->title->get();
$collapsible = new Collapsible();
$collapsible->collapsed->true();
$collapsible->collapsed->get();
$collapsible = new Collapsible();
$img = new Image();
$img->url->set('http://...');
$collapsible->add($img);
$collapsible->get(0);
$collapsible->delete(0);
$container = new Container();
$container->margins->responsive();
$detail = new Detail();
$detail->thumbnail->url->set('http://...');
$detail->thumbnail->crop->true();
$collapsible = new Collapsible('collapse1');
// OR
$collapsible = new Collapsible();
$collapsible->setId('collapse1');
$collapsible = new Collapsible();
$collapsible->getElementType();
$table = new Table();
$row = new \XModule\Helpers\Row();
$table->addRow($row);
$table->getRow(0);
$table->deleteRow(0);
$columnOption = new \XModule\Helpers\ColumnOption();
$table->addColumnOption($columnOption);
$table->getColumnOption(0);
$table->deleteColumnOption(0);
// Create root response element
$response = new XModuleResponse();
// Create root form element
$form = new Form();
$form->relativePath->set('./');
// Create inputs
$nameInput = new TextInput();
$nameInput->name->set("first-name");
$nameInput->label->set("First Name");
$selectState = new SelectMenu();
$selectState->name->set("state");
$selectState->label->set("State");
$optionLabels = ['New York', 'Georgia', 'California'];
$optionValues = ['NY', 'GA', 'CA'];
$selectState->addOptionLabel($optionLabels);
$selectState->addOptionValue($optionValues);
// OR store in associative array
//$optionValues = [
// //label - value
// 'New York' => 'NY',
// 'Georgia' => 'GA',
// 'California' => 'CA'
//];
//foreach($optionValues as $label => $value){
// $selectState->addOptionLabel($label);
// $selectState->addOptionValue($value);
//}
$comments = new TextArea();
$comments->name->set('comments');
$comments->label->set('Comments');
// Add fields to form
$form->add([$nameInput, $selectState, $comments]);
// Add form to root response element
$response->add($form);
// Print JSON response
echo json_encode($response);
// Create root response element
$response = new XModuleResponse();
// Create multicolumn element
$columns = new MultiColumn(2);
// Create content
$text = new Detail();
$text->title->set('Welcome');
$text->body->set('<p>See to the right</p>');
$image = new Image();
$image->url->set('https://image.shutterstock.com/image-photo/large-beautiful-drops-transparent-rain-260nw-668593321.jpg');
// Add content to multicolumn
$columns->add(0, $text);
$columns->add(1, $image);
// Add multicolumn to root response element
$response->add($columns);
// Print JSON response
echo json_encode($response);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.