Question

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!

Was it helpful?

Solution

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,

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top