<?php

defined('_JEXEC') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use NP\Factory as NpFactory;

class NicepageViewProduct extends BaseHtmlView
{
    /**
     * @param null $tpl
     *
     * @return mixed
     */
    public function display($tpl = null)
    {
        $app = Factory::getApplication();
        //$pageId = $app->input->get('page_id', ''); TODO
        $productName = $app->input->get('product_name', '');

        $templateName = $productName === 'product-list' ? 'products' : 'product';
        $page = NpFactory::getTemplate($templateName);
        $page->setProductName($productName);
        //$page = NpFactory::getPage($pageId); TODO
        //$page->setProductName($productName); TODO
        $page->buildPageElements();
        $this->html = $page->getHtml();
        return parent::display($tpl);
    }
}
