Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

8 Commits

Repository files navigation

Sage 9 Blocks and fields

Simply create a wrapper to your block and add the fields you need.

Requirements

  • Sage 9
  • PHP <= 7.2
  • Advanced Custom Fields

Custom Fields

All the management of custom fields is driven by WordPlate ACF.

https://github.com/wordplate/extended-acf

Installation

composer require inrage/blocks

Create a block

First, create a new folder in your theme directory.

mkdir app/Blocks

And then create a new file Testing.php in that folder.

<?phpnamespaceApp\Blocks;
useinRage\Blocks\Block;
useWordPlate\Acf\Fields\Text;
class Testing extends Block
{
public$title = 'Testing';
public$description = 'Testing block';
public$icon = 'format-image';
protectedfunctionfields(): array
{
return [
Text::make('Text', 'text')->required()
];
}
}

View

Create a new file into the resources/views/blocks folder.

<divclass="{{$block->classes}}">
<h2>{{$text}}</h2>
</div>

Fields per view

If you need to use custom fields per page, you can do it directly with this package.

Structure

To use this feature, you must create a subdirectory in the "app" directory, it must be named Fields.

Be careful, the name of your file/class must not be the same as the controllers.

We suggest you to use FrontPageField for example.

<?phpnamespaceApp\Fields;
useinRage\Blocks\Field;
useWordPlate\Acf\Fields\Text;
useWordPlate\Acf\Location;
class FrontpageFields extends Field
{
public$title = 'Homepage management';
protectedfunctionfields(): array
{
return [
Text::make('title')->required()
];
}
protectedfunctionlocation(): Location
{
return Location::if('page_type', 'front_page');
}
}

About

Simply create a wrapper to your block and add the fields you need.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages