PHPackages                             magently/module-content-setup - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. magently/module-content-setup

ActiveMagento2-module

magently/module-content-setup
=============================

Magently Content Setup module for Magento 2.

v1.0.1(3y ago)41.5k1OSL-3.0PHPPHP &gt;=7.1

Since Aug 26Pushed 3y ago1 watchersCompare

[ Source](https://github.com/magently/module-content-setup)[ Packagist](https://packagist.org/packages/magently/module-content-setup)[ RSS](/packages/magently-module-content-setup/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (4)Used By (0)

Magently Content Setup Module
=============================

[](#magently-content-setup-module)

Installation
------------

[](#installation)

To install the module, run the following commands:

```
composer require magently/module-content-setup
php bin/magento setup:upgrade

```

Usage
-----

[](#usage)

Now you can use the module in your code. Inject `Magently\ContentSetup\Model\ContentSetupFactory` in your UpgradeData / PatchData class - a Factory is used here so that you can use this module in different modules in the project, for example:

```
  public function __construct(\Magently\ContentSetup\Model\ContentSetupFactory $contentSetupFactory)
  {
      $this->contentSetupFactory = $contentSetupFactory;
  }

```

Then create an object from a Factory passing the name of your module, for example:

```
/** @var \Magently\ContentSetup\Model\ContentSetup $setup */
$setup = $this->contentSetupFactory->create(['moduleName' => 'Magently_TestModule']);

```

From now on, you can use the module to upload your content:

```
$setup->setupPage('test_page');
$setup->setupBlock('test_block');
$setup->setupEmailTemplate('test_email');
$setup->setupVariable('test_variable', 'TEST VARIABLE');

```

Cms Pages, Cms Blocks and Email Templates must be placed in the structure of your module: `app/code/VendorName/ModuleName/Setup/Content/{COMPONENT_NAME}`, e.g. `app/code/Magently/TestModule/Setup/Content/Block/test_block.html` and `app/code/Magently/TestModule/Setup/Content/Block/test_block.php`

files will be used to create / update a block with a `test_block` identifier. Put the content of the block in the `.html` file. In the `.php` file, put the data as an array with keys such as `name` or `is_active`:

```
// file: app/code/Magently/TestModule/Setup/Content/Block/test_block.php
