PHP code example of codekanzlei / cake-frontend-bridge
1. Go to this page and download the library: Download codekanzlei/cake-frontend-bridge 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/ */
codekanzlei / cake-frontend-bridge example snippets
action() {
$this->FrontendBridge->setJson(
'varName',
'this is sample text');
}
public function editModal ($id = null) {
$user = $this->Users->get($id);
if ($this->request->is(['patch', 'post', 'put'])) {
$user = $this->Users->patchEntity($user, $this->request->data);
if ($this->Users->save($user)) {
// prevent redirecting or reloading of the current page
$this->FrontendBridge->setJson('success', true);
}
}
$this->set(compact('user'));
}
// CkTools button
<?=$this->CkTools->button('edit_label', [
'controller' => 'Users',
'action' => 'editModal',
$user->id
],
// block interaction with the view file 'behind' the modal element
['additionalClasses' => 'modal-form']
)
public function index() {
// renders index.ctp
}
public function search() {
$users = null;
if ($this->request->is(['patch', 'post', 'put']) && !empty($this->request->data['search'])) {
// search UsersTable for entities that contain
// request->data['search'] in field 'username'
$users = TableRegistry::get('Users')->find()
->where(['username LIKE' => '%' . $this->request->data['search'] . '%'])
->all();
}
$this->set(compact('users'));
}
if(!empty($users)) :
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.