Skip to content

Instantly share code, notes, and snippets.

@kohki-shikata
Created December 13, 2020 10:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kohki-shikata/6bea69e3c455ad608cc36fbbf2cc2f2d to your computer and use it in GitHub Desktop.
Save kohki-shikata/6bea69e3c455ad608cc36fbbf2cc2f2d to your computer and use it in GitHub Desktop.
concrete5 test packages
<!-- /packages/test_package/db.xml -->
<?xml version="1.0"?>
<schema version="0.3">
<table name="YoutubeAPIKey">
<field name="apikey" type="X2">
</field>
</table>
</schema>
<!-- /packages/test_package/config/singlepages.xml -->
<?xml version="1.0"?>
<concrete5-cif version="1.0">
<singlepages>
<page name="Test Package" path="/dashboard/system/test_package"
filename="/dashboard/system/test_package.php" pagetype="" description=""
package="test_package"></page>
</singlepages>
</concrete5-cif>
<?php
// /packages/controllers/test_package/single_page/dashboard/system/test_package/test_package.php
namespace Concrete\Package\TestPackage\Controller\SinglePage\Dashboard\TestPackage;
use Concrete\Core\Page\Controller\DashboardPageController;
use \Concrete\Core\Validation\CSRF\Token;
class TestPackage extends DashboardPageController
{
public function view()
{
$token = $this->app->make('token');
$this->set('token', $token);
echo 'hoge';
}
public function save()
{
var_dump($_POST);
}
}
<?php
// /packages/test_package/test_package.php
namespace Concrete\Package\TestPackage\Controller;
use \Concrete\Core\Controller\Controller;
use \Concrete\Core\Validation\CSRF\Token;
defined('C5_EXECUTE') or die(_("Access Denied."));
class TestPackage extends Controller
{
public function save($args = null)
{
var_dump($_POST);
}
}
<?php
// /packages/single_pages/dashboard/system/test_package.php
defined('C5_EXECUTE') or die('Access Denied');
use \Concrete\Core\Validation\CSRF\Token;
$token = app('token');
$form = Core::make('helper/form');
?>
<form method="post" action="<?php echo $controller->action('save'); ?>">
<?php echo $token->output('save');?>
<div class="form-group">
<?php echo $form->label('apikey', t('API Key'))?>
<?php echo $form->text('apikey', $apikey); ?>
<div class="ccm-dashboard-form-actions-wrapper">
<div class="ccm-dashboard-form-actions">
<button class="pull-right btn btn-success" type="submit"><?php echo t('Submit');?></button>
</div>
</div>
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment