0

I created a custom Theme for our shop which works pretty fine.

Just one thing is bothering me: I created some words in the footer and want to link them to custom pages which only have static content. For example (just for better understanding) let's assume I created a link in the footer called "FAQ", when you click on it you will be redirected to https://my.shop/faq -> and this is a static page using my custom (let's call it) faq.phtml template.

I only found examples for custom m2 modules (containing routes blocks and controllers) but not for a theme. Also, I don't need functionality there. I simply want to show my static template.

Is there a tutorial or description for this case? I only found how to extend/overwrite available templates, bot not how to create a new one.

Thanks in advance!

1

I think you need to call your faq.phtml file in the FAQ page frontend. You should add the below code in your CMS page configuration and save.

{{block class="Magento\Framework\View\Element\Template" template="VendorName_ModuleName::YourTemplateFileLocation.phtml"}} 

You can change the VendorName_ModuleName as Magento_Theme and add your phtml file in that folder.

Forex phtml file page is app/design/frontend/your/theme/Magento_Theme/templates/faq.phtml

And in cms configuration,>> save

 {{block class="Magento\Framework\View\Element\Template" template="Magento_Theme::faq.phtml"}} 

Please clear Magento cache and review your changes in the frontend.

Please let me know if you are facing any issues.

Thanks,

4
  • is there a possibility to achieve this without creating the page in the cms-backend? I would like to do this completely via code
    – Java_Waldi
    Apr 12 '20 at 12:17
  • Yes, it is possible, you need to create a module, but as you have mentioned in your description you don't want to create a new module, correct? I would suggest, this is the best and simple way to add your phtml file on any cms page.
    – Nits
    Apr 13 '20 at 10:32
  • 1
    yes, I'd like to avoid creating a whole module.
    – Java_Waldi
    Apr 13 '20 at 17:16
  • Thanks, @Java_Waldi, if you need any help please email me on my email id nitish250788@gmail.com
    – Nits
    Apr 14 '20 at 8:19
0

You can achieve this by logging in to your Magento 2 admin backend dashboard, and navigating to Content > Elements > Pages.

Follow reference URL: [Till Step 6: Generate the Page]

https://www.mageplaza.com/kb/how-to-add-a-new-cms-page-magento-2.html

Note: Once you done with creating custom faq page just link page to footer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.