Jump to content

Custom Page On My Website


hei

Recommended Posts

Hi, 

 

I want to add a new page, differently by cms, in my website. I've created controller file:

 

<?php
class NegoziantiController extends FrontController
{
    /*
    public function setMedia()
    {
        $this->context->controller->addJS(_THEME_JS_DIR_ . 'custom-page.js');
        $this->context->controller->addCSS(_THEME_CSS_DIR_ . 'custom-page.css');
        parent::setMedia();
    }*/
    public function initContent()
    {
		$res = Db::getInstance()->executeS('
            SELECT `shop_name`, `link_rewrite`
            FROM `'._DB_PREFIX_.'marketplace_shop');
		
		foreach($res as $finale){
			$finale_due = array(array(‘nome’ => $finale['shop_name'], ‘link’ => $finale['link_rewrite']));
		}
        /*preparingdata for passing to the custom page*/
        $this->context->smarty->assign('finale' => $finale);
        /*data ends-here*/
        
        /*pass data to template file*/
        $this->setTemplate(_PS_THEME_DIR_ . 'negozianti.tpl');
        
        /*show left/ right columns - will be true and shown by default*/
        $this->display_column_left  = false;
        $this->display_column_right = false;
        
        /*call parent initcontent - this is for loading the site's default header, footer, left and right columns*/
        parent::initContent();
    }
}
?>

And tpl file added in template root:

<h3>Ciao</h3>
<p><strong>Test</strong></p>
<ul>
    {foreach from=$finale_due item=skill}
    <li>{$skill}</li>
    {/foreach}
</ul>

But nothign happens, what's wrong?

Can u help me?

 

Matteo

Link to comment
Share on other sites

Are you able to reach the page? do you see something or unable to load the controller?

did you added the page controller under seo & urls?

did you placed the files in the correct folders (controller/front & themes/your_theme)?

try to add above the public functions: public $php_self = 'negozianti';

Link to comment
Share on other sites

Load and load again, my friend.

Nothing.

<?php
class NegoziantiController extends FrontController
{
    public function initContent()
    {
                
		$aio = array('fname' => 'John', 'lname' => 'Doe', 'email' => '[email protected]');
        /*preparingdata for passing to the custom page*/
        $this->context->smarty->assign('aio' => $aio);
        /*data ends-here*/
        
        /*pass data to template file*/
        $this->setTemplate(_PS_THEME_DIR_ . 'negozianti.tpl');
        
        /*show left/ right columns - will be true and shown by default*/
        $this->display_column_left  = false;
        $this->display_column_right = false;
        
        /*call parent initcontent - this is for loading the site's default header, footer, left and right columns*/
        parent::initContent();
    }
    $php_self = 'negozianti';
}
?>

code right now. 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...