Jump to content

Add hook ClientAreaHeaderOutput


Dadou76620

Recommended Posts

Hello I just created a hook but this one return me an array

 

<?php

if (!defined("WHMCS"))
  die("This file cannot be accessed directly");

use Illuminate\Database\Capsule\Manager as Capsule;

function hook_template_variables_example($vars)
{
$data = Capsule::table('mod_wizardpanelsettings')->get();

foreach($data as $datas)
{
	$extra = json_decode(json_encode($datas), true);
}

$array = array(
  'favicon' => $extra['favicon']
);

return $array;
}

add_hook('ClientAreaHeaderOutput', 1, 'hook_template_variables_example');

?>

 

when I made a print_r($array); he return me Array ( [favicon] => teste url favicon ) as well header.tpl I call my variable {$favison}

 

Cordially ;)

Link to comment
Share on other sites

because you add the whole array as favicon value, lets apply small change

 

<?php 

if (!defined("WHMCS")) 
  die("This file cannot be accessed directly"); 

use Illuminate\Database\Capsule\Manager as Capsule; 

function hook_template_variables_example($vars) 
{ 
   $data = Capsule::table('mod_wizardpanelsettings')->get(); 

   foreach($data as $datas) 
   { 
       $extra = json_decode(json_encode($datas), true); 
       $favicon = $extra['favicon'];
   } 

   $array = array( 
     'favicon' => $favicon 
   ); 

   return $array; 
} 

add_hook('ClientAreaHeaderOutput', 1, 'hook_template_variables_example'); 

?>

Link to comment
Share on other sites

Thank you for your reply. I did like this it also works that correct?

 

<?php

if (!defined("WHMCS"))
  die("This file cannot be accessed directly");

use Illuminate\Database\Capsule\Manager as Capsule;

function hook_template_variables_example($vars)
{
global $smarty;

$data = Capsule::table('mod_wizardpanelsettings')->get();

foreach($data as $datas)
{
	$extra = json_decode(json_encode($datas), true);
}

$array = array(
	'favicon' => $extra['favicon']
);

$smarty->assign('wizardpanel', $array);
}

add_hook('ClientAreaHeaderOutput', 1, 'hook_template_variables_example');

?>

 

I have one last question

 

In the function 'function demo_output($vars)' how can retrieve the variable '{$WEB_ROOT}' ?

 

Cordially ;)

Link to comment
Share on other sites

I really like you but $WEB_ROOT displays nothing

 

<?php
function demo_output($vars) 
{
   $modulelink = $vars['modulelink'];
   $version = $vars['version'];
   $WEB_ROOT = $vars['WEB_ROOT'];
   $LANG = $vars['_lang'];
}
?>

:lol: what ActionHook point you are using with the "demo_output" function?

 

variables available are different based on what ActionHook point is called

Link to comment
Share on other sites

Hello

 

I have wanted to know how to recover the root or a whmcs eter settle in

 

function demo_output($vars) 
{
   $modulelink = $vars['modulelink'];
   $version = $vars['version'];
   $LANG = $vars['_lang'];
   $webroot = $vars['WEB_ROOT'];

 

my hook.php

 

add_hook('ClientAreaHeaderOutput', 1, demo_output);

 

Sorry if I do not fully understand the operation I am french :(

 

Cordially

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated