Jump to content

[SOLVED] how to display custom html in admin backoffice Orders page


vahid abdi

Recommended Posts

Hi
How can i display something in the Admin Orders page list before the list?

i already tried displayAdminAfterHeader hook but this hooks shows the content in all pages

to show in only Orders List page i could do if condition to check the $class_name of the controller calling, but still it shows my custom content in Order view page too and all Order Controller related pages

any suggestions?

Thanks.

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

32 minutes ago, Janett said:

Use same code with more restrictions ;)

Copy paste your code here, we can help you to improve it

So basically i want something like this:

this is last lines of code form file /{admin}/themes/default/template/header.tpl
 

	<div id="main">
		{include file='nav.tpl'}

		<div id="content" class="{if !$bootstrap}nobootstrap{else}bootstrap{/if}">
			{if isset($page_header_toolbar)}{$page_header_toolbar}{/if}
			{if isset($modal_module_list)}{$modal_module_list}{/if}

			{if $install_dir_exists}
				<div class="alert alert-warning">
					{l s='For security reasons, you must also delete the /install folder.'}
				</div>
			{/if}

			{hook h='displayAdminAfterHeader'}

			{hook h='dashboardZoneTwo' mod="MyModuleName"}


			{* end display_header*}

			{else}
			<body{if isset($lite_display) && $lite_display} class="ps_back-office display-modal"{/if}>
			<div id="main">
				<div id="content" class="{if !$bootstrap}nobootstrap{else}bootstrap{/if}">
					{/if}

I added this line of code : {hook h='dashboardZoneTwo' mod="MyModuleName"}
which calls a module i have created and returns html

this works fine but the only problem as i have mentioned is that i don't know how to specify this to work ONLY in AdminOrders Controller page which lists all the orders!

 

Link to comment
Share on other sites

8 minutes ago, Janett said:

Share PHP code about this hook in your module. Solution is not in template ;)

And no need to add a hook, you can do it with existing hook in Prestashop without modifications in template 

yes i know it's possible to register hook in my module without altering the template

the module hook is like this now. i've removed the part in which $user_orders array is created

public function hookDashboardZoneTwo()
{
	// Code to create user_orders array goes here
	//
	
	$this->context->smarty->assign(array(
		'user_orders' => $user_orders
	));
	return $this->display(__FILE__, 'dashboard_zone_two.tpl');
}

please note that this module and code works fine and as expected, and display desired html in DashboardZoneTwo

Link to comment
Share on other sites

Just now, Janett said:

You want to display that on Order listing or on dashboard ?

i would do this

public function displayAdminAfterHeader()
{
	// Code to create user_orders array goes here
	//
	
	$this->context->smarty->assign(array(
		'user_orders' => $user_orders
	));
	return $this->display(__FILE__, 'dashboard_zone_two.tpl');
}

this would display the template after header in all pages in back office(also above Orders listing)

how can i make this header hook to only work on Orders listing page :)

  • Like 1
Link to comment
Share on other sites

if ('AdminOrders' === Tools::getValue('controller')

&& false === Tools::getIsset('addorder')

&& false === Tools::getIsset('vieworder')

) {

// your code here

}

sorry I’m on my phone and I cannot use code display option 🤬

  • Like 1
Link to comment
Share on other sites

18 minutes ago, Janett said:

if ('AdminOrders' === Tools::getValue('controller')

&& false === Tools::getIsset('addorder')

&& false === Tools::getIsset('vieworder')

) {

// your code here

}

sorry I’m on my phone and I cannot use code display option 🤬

thanks for the effort. this is basically what I needed.

i had the following concern also in my original question:

are addorder and vieworder all the extra values that could be there besides order listing page?

for example if there is deleteorder page (which might not even exist) this condition would fail!

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

Addorder and vieworder are params used for display concerned pages.

deleteorder has no display view so this hook will never be called with this param, same for export option etc...

so with this code, you should see your extra content only on order listing page

Edited by Janett (see edit history)
  • Like 1
Link to comment
Share on other sites

13 minutes ago, Janett said:

Addorder and vieworder are params used for display concerned pages.

deleteorder has no display view so this hook will never be called with this param, same for export option etc...

so with this code, you should see your extra content only on order listing page

Thank you so much :)

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

  • 1 year later...
On 6/2/2019 at 6:51 PM, Janett said:

Addorder and vieworder are params used for display concerned pages.

deleteorder has no display view so this hook will never be called with this param, same for export option etc...

so with this code, you should see your extra content only on order listing page

Hello Janett, How is it going? Getting any new episode of "The Good Place"?

on a serious note: I am trying to edit the universalpay module. There is a function where you can collect some user input data. I am getting those data in the mysql but those are not being shown in the designated place on the order page. I guess it's not calling those fields rightly. The Data shown in the database is like - 

a:2:{s:4:"name";s:16:"ASDAASDAASDAASDA";s:7:"country";s:6:"France";}

Can you kindly help me to edit the module file/s so that i get the values there in the order page? 

Thank you

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