Skip to content

Commit

Permalink
feat: add short syntax for hiding plus icons in alfred
Browse files Browse the repository at this point in the history
  • Loading branch information
BernhardBaumrock committed Mar 17, 2023
1 parent 1fcf5d2 commit 65c59bf
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion RockFrontend.module.php
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,9 @@ public function addTopBar(&$html)
* 'fields' => 'foo,bar',
* ]);
*
* Show alfred without plus-icons for adding a new block before/after
* alfred($block, false);
*
* You can also provide fields as array when using the verbose syntax
* alfred($page, [
* 'trash' => false,
Expand All @@ -369,7 +372,12 @@ public function alfred($page = null, $options = [])
if (!$this->alfredAllowed()) return;

// support short syntax
if (is_string($options)) $options = ['fields' => $options];
if ($options === false) {
$options = [
'addTop' => false,
'addBottom' => false,
];
} elseif (is_string($options)) $options = ['fields' => $options];

// set flag to show that at least one alfred tag is on the page
// this flag is used to load the PW frontend editing assets
Expand Down Expand Up @@ -446,6 +454,12 @@ public function alfred($page = null, $options = [])
*/
public function alfredH($page = null, $options = [])
{
if ($options === false) {
$options = [
'addLeft' => false,
'addRight' => false,
];
}
return $this->alfred(
$page,
array_merge(['addHorizontal' => true], $options)
Expand Down

0 comments on commit 65c59bf

Please sign in to comment.