PHP code example of medienbaecker / kirby-modules

1. Go to this page and download the library: Download medienbaecker/kirby-modules 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/ */

    

medienbaecker / kirby-modules example snippets


// site/snippets/modules/text.php
<div id="<?= $module->slug() 

// site/templates/default.php
<?= $page->modules() 

<div id="<?= $module->slug() 

// Default container for the section called `modules`
<?= $page->modules() 

<?= $page->modules() 

 $page->renderModules(['theme' => 'dark']) 

// site/config/config.php
'medienbaecker.modules.model' => CustomModulePage::class,

// site/models/module.text.php
class ModuletextPage extends Medienbaecker\Modules\ModulePage {
  // your methods
}

use Medienbaecker\Modules\Module;

echo Module::factory([
  'type' => 'text',
  'content' => [
    'textarea' => 'Hello from code'
  ]
])->toHtml();

use Medienbaecker\Modules\Modules;

echo Modules::factory([
  ['type' => 'text', 'content' => ['textarea' => 'One']],
  ['type' => 'text', 'content' => ['textarea' => 'Two']],
]);

$page->createModule([
  'type' => 'text',
  'content' => [
    'textarea' => 'Imported text'
  ]
]);

$page->createModule($props, 'sidebar');

// site/config/config.php
return [
  // Create new modules visible instead of hidden (default: false)
  'medienbaecker.modules.autopublish' => true,

  // Override the page model for all module types
  'medienbaecker.modules.model' => CustomModulePage::class,
];