Jump to content

Using renderView() in a custom ModuleAdminController (PS1.6)


kaamyi

Recommended Posts

Hello,

I am trying to add a view to my back office module page but i cannot display anything with the renderview() function. I can already display my list with renderList() and it's working well. I also tried renderForm() and it works well too but it seem i can't get renderView() to display something.

    public function renderView(){

        if(!($config = $this->loadObject())){
            return;
        }

        $data = Config::getDataForm(Tools::getValue('id_config'));
        // var_dump($data);

        $this->tpl_view_vars = array(
            'id_config' => $data['id_config'],
            'prix' => $data['prix'],
            'hauteur' => $data['hauteur_passage']
            );

        return parent::renderView();

    }

This is a pretty basic code. My getDataForm($id_config) is basically getting fields from database in an array so that i can display it. I can see the var_dump displaying for a short time before displaying the blank page with prestashop header and footer. I tried to see if i was doing something wrong by checking other AdminControllers such as AdminCartsController or AdminCustomersController but it seems that their renderView() function is more or less written the same way.

Thanks in advance for your help !

Edited by kaamyi (see edit history)
Link to comment
Share on other sites

Nobody tried renderView()?

 

Ok i figured out i have to create the template.. It was really not easy to find out, i wish it had been explained in the documentation so that i hadn't loose all this time trying to find the proper way to do it.

Edited by kaamyi (see edit history)
Link to comment
Share on other sites

Maybe it need a file! when I try to add the follow file,it can display something....

 

example:        $this->addRowAction('view');     on AdminAddressesController 

 

admin\themes\default\template\controllers\addresses\helpers\view\view.tpl

 

 

more  information you can learn from:

http://doc.prestashop.com/display/PS15/Using+helpers+to+overload+a+back-office+template

Edited by aliabc (see edit history)
Link to comment
Share on other sites

Hi kaamyi,

 

With your reference from http://stackoverflow.com/questions/24995602/using-renderview-in-a-custom-moduleadmincontroller-ps1-6

 

i have created my own module which is having a backoffice controller file which is similar to order detail page in order page, when i click on the view link , i am getting a blank page. I followed your reference from stackoverflow and i created helpers/view/view.tpl , but i am getting nothing.

Link to comment
Share on other sites

hi kaamyi,

 

i got it i have put the view.tpl file in admin/themes/default/templates/controller/mycontrollername/helpers/view/view.tpl

 

thank you for your response, but how can we do with in the module directory.

 

could you put your directory path of module to put the view.tpl file for a module directory.

Link to comment
Share on other sites

  • 1 year later...

Hi, 

 

I am a presta newbie and I have a similar problem, I created a custom module with custom controller, then  under Administration->Menus I created a new admin menu with the new module and controller. After that I created a test template file under "modules/szilveszterfirst/views/templates/admin/szilveszter_first/helpers/view/test.tpl". Everything works fine, except the renderView function, the template file is loaded(I printed out the result), but in the admin page doesn't show anything. Is there any prerequisite, that I didn't do? e.g. the template should contain something special(actually contains a few html tags for test sake)? Is this the proper way to display content in back office under a menu with module?

class AdminSzilveszterFirstController extends ModuleAdminController {

    public function __construct() {
        $this->lang = false;
        parent::__construct();
    }
    
    public function initContent(){
        $this-> renderView();
        return parent::initContent();
    }
    public function renderView() {
        $this->base_tpl_view = 'test.tpl';
        //printf("<pre>%s</pre>",print_r(parent::renderView(),true));
        return parent::renderView();
    }
}
Edited by zsigmondszilveszter (see edit history)
Link to comment
Share on other sites

  • 2 years later...

Hi,

I have exactly  the same problem as zsigmondszilveszter. Created .tpl file in a proper way. File is loaded, but it is not rendered.

Have anyone resolve it? Maybe "ambassadors" will kindly help?

 

 

 

 

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...