I am new to Magento, I need to pass parameters to a cms page created through the backend under the cms section. The steps I followed to create a page are as follows:
- First of all, I added a new page layout using this answer.
- Then I added a new page from admin panel, and added the layout created in the previous step to this page.
- The page is created and I can access it using the url-key (custom-products) generated for this page, as
example.com/custom-products
The page content is loaded successfully.
Now my problem is, i want to pass a parameter to this url just like example.com/custom-products/1
, but when I write /1
at the end of the url, It takes me to the Not found page.
But when I add a query-string parameters (example.com/custom-products?param=1
) to this page the page works fine. But I don't want the parameter passed as query-string. I need it to be as example.com/custom-products/1
Any help in this regard would be really appreciating.
Bundle of thanks in advance.
Best Answer
You can't use following type of url for cms page
OR
Because CMS Router class take whole things as an identifier. In example it's create identifier for url like
AND
But when you create CMS page, you assign identifier 'custom-products' not custom-products/1 or custom-products/param/1, That's why it load nothing. Check following class
Check following line
How to overcome?
Create your own router and make your own way.
How you create Router?
You use an example of CMS module. Open config.xml and check following code sample
Create your router class like Vendor_Module_Controller_Router.