0

I am still so new to Magento and still learning.

I want to create a landing page for a brand promo or a certain product advertisement. Something like this https://advertising.amazon.com/resources/ad-specs/landing-pages

How can I do that through code changes and be customizable in the admin panel?

Thanks.

0

3 Answers 3

0

If your landing page contain static content then you can create CMS Page for this thing in Magento 2.

Here is the step for create CMS page and its routing in Magento 2.

Add New CMS Page in Magento 2

If this helps hit like.

Happy coding :)

Hiren Patel

7
  • Would it be better to do it through code changes instead of CMS? Commented Oct 2, 2020 at 18:02
  • If you need easiest way then CMS Page and its also as per Magento standard. And, If you want to create new module and you want to go through that then you have to create new routing using routes.xml, new frontend controller, new layout xml file and phtml file. Commented Oct 2, 2020 at 18:05
  • may I know whats the pro and cons of creating that through CMS page instead of creating new module? Commented Oct 2, 2020 at 18:10
  • CMS Page is easy to change because its provided default by Magento 2 admin. Its contain HTML editor. Commented Oct 2, 2020 at 18:12
  • If you have basic knowledge about only html then you can edit in future. one problem with custom module is that you have to setup SEO friendly URL differently using URL Rewrite where in CMS Page you just have to URL Key which you want to add. it's too easy Commented Oct 2, 2020 at 18:19
1

You can use a cms page to create the landing page. However, to have this cms page to be rendered on a url that has several parts like yours (/resources/ad-specs/landing-pages), you will need to add a router in a custom module.

the link from Mageplaza seems to be point: https://www.mageplaza.com/magento-2-module-development/how-to-create-controllers-magento-2.html. Once you are successful with this code, then, the idea to listen to your url within the router and forward to a cms page:

the code below should be helpful:

if (strpos($request->getPathInfo(), 'resources/ad-specs/landing-pages') !== false) { $request->setPathInfo('/ad-specs-landing-pages'); $request->setModuleName('cms') ->setControllerName('page') ->setActionName('view'); $request->setParams(['page_id' => 3]); // 3 would need to be replaced by your cms page id return $this->actionFactory->create( \Magento\Framework\App\Action\Forward::class ); } 
1

No coding is required to complete this task.

Go to Admin/Content/Pages and click on Add new page and you're good to go.

You can also use HTML format using above method.

enter image description here

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.