Jump to content

help link in custom module


thx2012

Recommended Posts

I have working custom module that displays currently one link within front office.. I would like to add multiple links to different templates within module (see attached image example).

 

 

Can someone please guide me on how to add multiple links in front office to each perspective template. Currently I’m linking only to one template, and I would like to adjust:

 

My Main file

mymodule.php

 public function hookDisplayLeftColumn($params)
 {
   $this->context->smarty->assign(
       array(
           'my_module_name' => Configuration::get('MYMODULE_NAME'),
           'my_module_link' => $this->context->link->getModuleLink(‘mymodule’, 'template1')
       )
   );
   return $this->display(__FILE__, 'views/hooks/left.tpl');
 }

My Hook

views/hooks/left.tpl

<!-- Block mymodule -->
<div id="mymodule_block_left" class="block mymodule_block_left">
 <p class="title_block">Title</p>
 <div class="block_content list-block">
<ul>
     <li><a href="{$my_module_link}" text="link1" alt="alt-text-link1" title="title-text-link1">link1</a></li>
   </ul>
 </div>
</div>
<!-- /Block mymodule -->

My Templates

views/templates/front/template1.tpl

views/templates/front/template2.tpl

views/templates/front/template3.tpl

 
I forgot to include my controllers php file (edited)..
 
My controllers
controllers/front/template1.php
 
    public function initContent() {
      global $smarty;
      parent::initContent();


      $this->context->smarty->assign(array(
        'path' => 'Link1',
      ));

      $this->context->smarty->assign('img_ajax_loader', '/modules/' . $this->module->name . '/views/img/ajax-loader.gif');


      $this->setTemplate('template1.tpl');
    }

controllers for each template file.

 

controllers/front/template1.php

controllers/front/template2.php

controllers/front/template3.php

 

I think I may of answered my own post.. I'll attempt test on workstation in morning and update results.  Anyone have suggestion that can help me, I would appreciate it.

post-92142-0-03420700-1458675023_thumb.jpg

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

I add the three urls and they all link to same file (template1).

In display tpl file /views/hooks/left.tpl

<li><a href="{$my_module_link}" text="link1" alt="alt-text-link1" title="title-text-link1">link1</a></li>
<li><a href="{$my_module_link}" text="link2" alt="alt-text-link2" title="title-text-link2">link2</a></li>
<li><a href="{$my_module_link}" text="link3" alt="alt-text-link3" title="title-text-link3">link3</a></li>

In main php file mymodule.php I can only link over to one of the templates (tempalte1).

$this->context->smarty->assign(
        array(
            'my_module_name' => Configuration::get('MYMODULE_NAME'),
            'my_module_link' => $this->context->link->getModuleLink(‘mymodule’, 'template1')
        )

I get class & parse error if I simply add the following in main php file:

$this->context->smarty->assign(
        array(
            'my_module_name' => Configuration::get('MYMODULE_NAME'),
            'my_module_link' => $this->context->link->getModuleLink(‘mymodule’, 'template1')
            'my_module_link' => $this->context->link->getModuleLink(‘mymodule’, 'template2')
            'my_module_link' => $this->context->link->getModuleLink(‘mymodule’, 'template3')
        )

Any suggestions on how I can link the other template files?

 

 

 

 

 

 

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