Jump to content

[Solved] Module Configure link as New Tab


Recommended Posts

Hello,

I need a little help setting up a new back office tab. I wanted to add a new tab to the back office so that I can quickly go to the settings of my blog module. I have found a few other posts about this however when I tried to do it the first time I totally broke the site, after fixing everything I tried again with undesirable results again. So I am reaching out to the community for a better understanding of how to do this, I know from my searches that I am not the only one who wishes to understand this in a detailed way so I figured I would try and post about this process. Please break down the steps to make this happen I appreciate your time many thanks ahead of time.

 

How to create a new BO TAB with a modules configure settings in the tab??

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

  • 5 weeks later...
  • 3 weeks later...

In the back office go to Employees> tabs>new tab> Then you need to fill out the fields, if your connecting the tab to a already installed module you will need to add the correct names, if you connecting to a new page one will need to be created such as admin>tabs>AdminMyTabPage.php and configured accordingly on he new tab fields.

post-149621-0-21030700-1344265954_thumb.png

Link to comment
Share on other sites

  • 2 months later...

@ovom:

 

If you go to your module's configuration page, you will see in the address bar the details required for the input fields (see attached image below). The 'controller' will be the CLASS and the 'configure' will be the MODULE.

 

33m279g.jpg

 

However, I'm currently using Prestashop 1.5.1 and there seems to be a bug, in that the MODULE field doesn't seem to work. So my workaround is to fill the CLASS field with both the controller and the module like so: AdminModules&configure=slideric

 

PS: The settings for Prestashop 1.5.1 is under Administration > Menus

  • Like 1
Link to comment
Share on other sites

  • 4 weeks later...

@kelvs

 

Yes, the same thing happens if you create a 'Quick Access' link from the 'Administration' menu for back office shortcuts. In the "Quick Access > Add Menu" page, there's even an instruction as follows:

 

"If it's an URL that comes from your Back Office, you must NOT put a security token."

 

Meaning, I assume, that if you were to create a back office shortcut, you were not supposed to include the security token in the URL, thus the security warning. So I guess since we created the links ourselves and we know what we were doing, it should be save. Just click on the "I understand the risks and I really want to display this page" and you should be good to go.

  • Like 2
Link to comment
Share on other sites

  • 3 months later...
  • 2 months later...

I was searching the solution to security token warning and kinda found something. It is not "professional", but I got rid of this horrible "invalid token" warning in BO tabs I created myself (thanks to @Aldi M's instructions above).

Now the button "I understand the risk..." clicks itself ;)

 

So, what I did was:

1. in admin/themes/default/template/invalid_token.tpl just after <head> I added:

 

 

<script type="text/javascript">

 

function init(){

 

var linkPage = document.getElementById('dynLink').href;

window.location.href = linkPage;

}

 

onload=init;

 

</script>

 

2. In the same file I added the

 

id="dynLink"

 

to <a href="{$url}" method="get" style="float:left;background: #E3E3E3;border-color: #CCCCCC #BBBBBB #A0A0A0;border-left: 1px solid #BBBBBB;border-radius: 3px 3px 3px 3px;border-right: 1px solid #BBBBBB;border-style: solid;border-width: 1px;color: #000000;margin: 20px 10px;padding:10px;text-align:center;vertical-align:middle;">

 

so it looks like this now:

 

<a href="{$url}" id="dynLink" method="get" style="float:left;background: #E3E3E3;border-color: #CCCCCC #BBBBBB #A0A0A0;border-left: 1px solid #BBBBBB;border-radius: 3px 3px 3px 3px;border-right: 1px solid #BBBBBB;border-style: solid;border-width: 1px;color: #000000;margin: 20px 10px;padding:10px;text-align:center;vertical-align:middle;">

 

The solution is based on this thread: http://www.webdeveloper.com/forum/showthread.php?97081-Auto-click-a-link-Please-help!

  • Like 3
Link to comment
Share on other sites

hey. same issue. trying to get configure links for modules on other pages with correct token. i see all the config links have same token. how would i call that?

 

Ive found.

if (Tools::getValue('redirect') == 'config' && Tools::getValue('module_name') != '' && $return == '12' && Module::isInstalled(pSQL(Tools::getValue('module_name'))))
			Tools::redirectAdmin('index.php?controller=adminmodules&configure='.Tools::getValue('module_name').'&token='.Tools::getValue('token').'&module_name='.Tools::getValue('module_name').$params);
		Tools::redirectAdmin(self::$currentIndex.'&conf='.$return.'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name.'&anchor=anchor'.ucfirst($module->name).(isset($modules_list_save) ? '&modules_list='.$modules_list_save : '').$params);

<a href="{$url}" method="get" style="float:left;background: #E3E3E3;border-color: #CCCCCC #BBBBBB #A0A0A0;border-left: 1px solid #BBBBBB;border-radius: 3px 3px 3px 3px;border-right: 1px solid #BBBBBB;border-style: solid;border-width: 1px;color: #000000;margin: 20px 10px;padding:10px;text-align:center;vertical-align:middle;">
		{l s='I understand the risks and I really want to display this page'}
</a>

<div class="row-actions-module">
  {if !isset($module->not_on_disk)}{$module->optionsHtml}{else} {/if}
</div>
is the code for the modules links, ie config delete reset...

Link to comment
Share on other sites

@ovom:

 

If you go to your module's configuration page, you will see in the address bar the details required for the input fields (see attached image below). The 'controller' will be the CLASS and the 'configure' will be the MODULE.

 

33m279g.jpg

 

However, I'm currently using Prestashop 1.5.1 and there seems to be a bug, in that the MODULE field doesn't seem to work. So my workaround is to fill the CLASS field with both the controller and the module like so: AdminModules&configure=slideric

 

PS: The settings for Prestashop 1.5.1 is under Administration > Menus

 

how do you get the token part right?

i noticed all the modules' delete configure delete.. have the same token... so to make a link right to the configure of the module.

how do i call that correct token?

Link to comment
Share on other sites

how do you get the token part right?

i noticed all the modules' delete configure delete.. have the same token... so to make a link right to the configure of the module.

how do i call that correct token?

 

you can get token from $_GET[''] variable - both for controller (php script) and for template (smarty code $smarty.get)

Link to comment
Share on other sites

  • 1 year later...

I was searching the solution to security token warning and kinda found something. It is not "professional", but I got rid of this horrible "invalid token" warning in BO tabs I created myself (thanks to @Aldi M's instructions above).

Now the button "I understand the risk..." clicks itself ;)

 

So, what I did was:

1. in admin/themes/default/template/invalid_token.tpl just after <head> I added:

 

 

<script type="text/javascript">

 

function init(){

 

var linkPage = document.getElementById('dynLink').href;

window.location.href = linkPage;

}

 

onload=init;

 

</script>

 

2. In the same file I added the

 

id="dynLink"

 

to <a href="{$url}" method="get" style="float:left;background: #E3E3E3;border-color: #CCCCCC #BBBBBB #A0A0A0;border-left: 1px solid #BBBBBB;border-radius: 3px 3px 3px 3px;border-right: 1px solid #BBBBBB;border-style: solid;border-width: 1px;color: #000000;margin: 20px 10px;padding:10px;text-align:center;vertical-align:middle;">

 

so it looks like this now:

 

<a href="{$url}" id="dynLink" method="get" style="float:left;background: #E3E3E3;border-color: #CCCCCC #BBBBBB #A0A0A0;border-left: 1px solid #BBBBBB;border-radius: 3px 3px 3px 3px;border-right: 1px solid #BBBBBB;border-style: solid;border-width: 1px;color: #000000;margin: 20px 10px;padding:10px;text-align:center;vertical-align:middle;">

 

The solution is based on this thread: http://www.webdeveloper.com/forum/showthread.php?97081-Auto-click-a-link-Please-help!

 

 

This solution is good but not permanent solution...would be better if we will get permanent solution...

Link to comment
Share on other sites

  • 6 months later...
  • 6 months later...
  • 6 months later...

Casually landed in this topic, and have a couple of minutes to explain my solution.

 

  1. Create a new tab that links to one of your module's admin controllers (for example MyModulePreferencesController).
  2. In the Preferences admin controller's class, just define the init() class, call parent::init() and do a redirect: 
    Tools::redirectAdmin($this->context->link->getAdminLink('AdminModules') . '&configure=' . Tools::safeOutput($this->module->name));
    
Link to comment
Share on other sites

  • 1 month later...
  • 6 months later...

 

Casually landed in this topic, and have a couple of minutes to explain my solution.

 

  1. Create a new tab that links to one of your module's admin controllers (for example MyModulePreferencesController).
  2. In the Preferences admin controller's class, just define the init() class, call parent::init() and do a redirect: 
    Tools::redirectAdmin($this->context->link->getAdminLink('AdminModules') . '&configure=' . Tools::safeOutput($this->module->name));
    

 

Hello,

 

Can you give a complete code of controller's class please?

 

Thanks :)

Link to comment
Share on other sites

Hello,

 

Can you give a complete code of controller's class please?

 

Thanks :)

 

Can't you read?

class AdminPreferencesController extends ModuleAdminController
{

    /**
     * @see AdminController->init();
     */
    public function init()
    {

        parent::init();

        // Just redirect to the module configuration page
        Tools::redirectAdmin($this->context->link->getAdminLink('AdminModules') . '&configure=' . Tools::safeOutput($this->module->name));

    }

}
  • Like 2
Link to comment
Share on other sites

 

Can't you read?

class AdminPreferencesController extends ModuleAdminController
{

    /**
     * @see AdminController->init();
     */
    public function init()
    {

        parent::init();

        // Just redirect to the module configuration page
        Tools::redirectAdmin($this->context->link->getAdminLink('AdminModules') . '&configure=' . Tools::safeOutput($this->module->name));

    }

}

Thanks :)

Link to comment
Share on other sites

  • 1 year later...
  • 1 year later...

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