API-based ecommerce

Permalink
I have the following requirements:
- I would like to integrate an API-based ecommerce solution with concrete5. That means, that all data about products, customers and so on is not stored in the concrete5 database but in the cloud and the data is retrieved as necessary.
- I need now a way to show for each product a single product page. Now, I do not want to create a concrete5 page for each product. Rather I would like to have a Route that looks something like the following:
Route::register('/en/products/{productUrlSlug}', '\Concrete\Package\MyPackage\Controller\Frontend\SingleProduct::view')

and have a view template at
\packages\my_package\views\frontend\single_product.php

So each product url is mapped to the view function of my SingleProduct Controller where I can get the product infos from the API using the url slug of the product. However, as this is not a concrete5 page, I cannot use
$this->inc('my_theme/elements/header.php')

to get all the concrete5 theme stuff that builds the website, because in there, header_required.php is loaded and that needs a page to be set.

Now my question is: How do I get the content of my single_product view template to render within the view.php from my theme, i.e. the content of single_product.php should be delivered as $innerContent in the view.php template.

I hope it is clear, what I would like to achieve.

creatingweb
 
Justin1978 replied on at Permalink Reply
Justin1978
I hope I understood your problem correctly. I can understand you don't want a page for each product. Other E-commerce solutions don't do that either and with a large shop you would get a trillion pages.

Why don't you create a single page? Then you could route your requests to this page and still have Concrete's methods available. You could still use your custom route but map it to a method in your single page controller.