Download the PHP package rocketweb/module-content-update without Composer
On this page you can find all versions of the php package rocketweb/module-content-update. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download rocketweb/module-content-update
More information about rocketweb/module-content-update
Files in rocketweb/module-content-update
Package module-content-update
Short Description Module for creating and updating static content using data scripts.
License GPL-3.0
Informations about the package module-content-update
RocketWeb_ContentUpdate
Module takes care of creating and updating static content using data scripts.
Installation
Install using Composer
To install manually download the module contents into app/code/RocketWeb/ContentUpdate
Configuration
Create new module ProjectNamespace/ContentUpdate in the app/code
directory using steps below:
Replace ProjectNamespace in the steps below with project or vendor namespace
-
Create
composer.json
-
Create
registration.php
-
Create
etc/module.xml
-
Clone
vendor/rocketweb/module-content-update/Setup/UpgradeData
toapp/code/ProjectNamespace/ContentUpdate/Setup/UpgradeData.php
- Open
Setup/UpgradeData.php
and replace
with
-
Clear example functions in UpgradeData.php and add your own (see reference in the next section)
- Run
Usage
Adding update functions and triggering them
- Open
ProjectNamespace_ContentUpdate/etc/module.xml
- Change setup_version attribute from x.y.z to x.y.z++ eg. 1.0.9 to 1.0.10
- Open
ProjectNamespace_ContentUpdate/Setup/UpgradeData.php
- Scroll to the bottom of the file
- Before the closing braces add your function using a unique name (createUIPage). Use instructions below as a reference for creating and updating various elements.
- When done creating function scroll up and find $setup->endSetup();
-
The last entry before that line should look something like
- Duplicate this entry and update both setup version number (to match the one from module.xml) and function name (to the recently created one)
- When done save the file and run
bin/magento setup:upgrade
- Go to the page/block you created to confirm it's working properly
If you need to revert module's setup_version number while making adjustments you can do that by modifying a database entry in setup_module table. Make sure to revert both schema_version in data_version before running
magento setup:uprade
. Note that you can only change it via db until you commit.
Update functions
Create a new CMS page
Update existing CMS page
Delete existing CMS page
Create a new CMS block
Update existing CMS Block
Delete existing CMS block
Create new configurations
Update existing configuration
Delete existing configuration
Create a widget
Update transactional email template
public function updateEmailTemplate($helperSetup)
{
// This is an example function
return;
$template = $helperSetup->getTemplateByCode('Lore Ipsum Forgot Password');
if ($template->getId() <= 0) {
return;
}
$text = <<<EOD
{{template config_path="design/email/header_template"}}
<p class="greeting">{{trans "%name," name=\$customer.name}}</p>
<p>{{trans "There was recently a request to change the password for your account."}}</p>
<p>{{trans "If you requested this change, set a new password here:"}}</p>
<table class="button" width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<table class="inner-wrapper" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td align="center">
<a href="{{var this.getUrl(\$store,'customer/account/createPassword/',[_query:[id:\$customer.id,token:\$customer.rp_token],_nosid:1])}}" target="_blank">{{trans "Set a New Password"}}</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
<p>{{trans "If you did not make this request, you can ignore this email and your password will remain the same."}}</p>
{{template config_path="design/email/footer_template"}}
EOD;
$text = $helperSetup->cleanTemplateText($text);
$variables = <<<EOD
{
"var customer.name":"Customer Name",
"var this.getUrl(\$store, 'customer/account/createPassword/', [_query:[id:\$customer.id, token:\$customer.rp_token]])":"Reset Password URL"
}
EOD;
$variables = str_replace("\n", '', $variables);
$data = [
'template_text' => $text,
'template_styles' => '',
'template_type' => TemplateTypesInterface::TYPE_HTML,
'template_subject' => '{{trans "Reset your %store_name password" store_name=$store.getFrontendName()}}',
'orig_template_code' => 'customer_password_forgot_email_template',
'orig_template_variables' => $variables,
];
$template->addData($data);
$template->save();
}