How to use script for Magento 2 for auto creation of cms pages using your own template based on magezon page builder or based on HTML?
How to use script for Magento 2 for auto creation of cms pages using your own template based on magezon page builder or based on HTML?
You can Buy Its free now! Goaskle / GoCms extension here
- Download magento 2 extension named GoAskle / GoCms
- Extract zip with extension into <magento 2 root>/app/code folder. Dont run any magento 2 ssh commands before point 4 will be completed.
- Make sure that all folders inside extracted extension are with 755/775 rights and files with 644/664 rights
- Edit <magento 2 root>/app/code/GoAskle/GoCms/Setup/Setup/UpgradeData.php lines 35 and 36:
- Make sure that commented array of cities which dont needed for you. If not uncomment required and comment not needed.
- Make sure twice that array with cities uncommented and second line with cities commented. Only one line from 35 and 36 must be active.
5. Create cms page as template for insert into many cms pages using Magezon page builder or using standard editor of magento 2. Copy code usung HTML button (if use magento 2 editor)
6. Edit <magento 2 root>/app/code/GoAskle/GoCms/Setup/Setup/UpgradeData.php file in line 42-43 with <<<EOD in begin and in EOD in the end. Place there content of your template and use varible $fval as current city. Make sure that your content not contain double backslashes \\ -- if you have it then replace it with \\\, also replace all \n to \\n
7. Edit <magento 2 root>/app/code/GoAskle/GoCms/Setup/Setup/UpgradeData.php file in line 49-60 inside $data varible and make sure that title, meta title, meta description, meta keywords and identifier (url_key) looks like as you wanted.
8. Edit <magento 2 root>/app/code/GoAskle/GoCms/Setup/etc/module.xml file only in line 4: from current setup_version to +1. Dont use more than 1. Example 0.1.16 need to increase +1 and it will be 0.1.17 and save it.
9. Go to list of your existing cms pages and make sure that no one from existing cms pages have same url_keys as you planned to generate OR script will NOT WORK. Because this script can not create new cms page if cms page with same url_key already exists. So delete pages if needed before go to next step.
10. Go to SSH under cpanel user (may use terminal) into root of your magento 2 and run: bin/magento setup:upgrade or php bin/magento se:upg
11. done
12. If you need to run your script again then you need to change <magento 2 root>/app/code/GoAskle/GoCms/Setup/Setup/UpgradeData.php
and after this ALWAYS increase setup_version +1 in this file (if you will not increase setup_version then script will not be started)
<magento 2 root>/app/code/GoAskle/GoCms/Setup/etc/module.xml
because this setup_version is trigger for run script and using point 10 again to start running this script