First of all, I am new here and my English is not good enough so i am sorry about that. Here is my question;
I am trying to code an addon module for WHMCS 5 and i want to use bootstrap modal windows in my addon's pages. I am trying to add css and js lines in to the main page of my addon. I want to put them inside the head tag by coding, i do not want to change the template file and i know that it is possible to do this because "WHMCS's Project Planner" module is doing this successfully. I can see that in the source codes of pages.
When i looked into the admin template's "header.tpl" file, there are two smarty codes. {headoutput} and {headeroutput}. They are positioned like below;
<head>
{headoutput}
</head>
<body>
{headeroutput}
I have made lots of research about how to send my code to {headoutput} by my module .php file. If anybody knows how to do this, please i need help very much.
Your help is very appreciated. Best Regards, Caner
I have found the solution for reading more documents in WHMCS Documentation and some other places.
First of all as i learnt, after WHMCS 4, developers changed some rules and WHMCS's {headoutput} and {headeroutput} smarties in the templates are not directly editable by the code anymore. WHMCS uses Hooks for adding user codes between special html blocks. And here is the solution about my problem.
Doc. Ref. 1: http://docs.whmcs.com/Hooks
Doc. Ref. 2: http://docs.whmcs.com/Hooks:System
After we did the essential things to create an addon module, we are creating a new file in the module folder named "hooks.php". WHMCS is including this file directly, without any decleration to include, in to our module. In the "hooks.php" we need to create a hook function, explained as in the Doc. Ref. 1. Your function does not need to have a special name but WHMCS developer advices you to use a hierarchy like starting with "hook_", followed by the filename, and then the particular action or task that hook is performing. For example;
function hook_youraddonmodule_adminHeadBlock($vars) {
//Here is my custom code below
$headoutput = '<link href="../includes/jscript/css/bootstrap.min.css" rel="stylesheet">';
return $headoutput;
}
After you name the function, you must type your code between the curly braces that according to your needs. I put bootstrap css file link that i wanted to be included by all my module pages' head blocks. We declared a hook function and then we need to prepare it to be used by WHMCS's predefined hook places as explained int the Doc. Ref. 2. To put the code between head block we have to use "AdminAreaHeadOutput" hook decleration. Here is the code that i used;
// Define Client Login Hook Call
add_hook("AdminAreaHeadOutput",1,"hook_youraddonmodule_adminHeadBlock");
This definition means that we have added a hook to admin area head output and it's priority is first (1). Actually i do not know why we need a priority about hooks and i did not made a research about it but if it has done, there must be an advantage of it :) Now all you need to save the hook file and upload it to your server. All done. I hope it helps the people who is looking for this kind of tricks.
Update:
I have recognized that, when you create a hook and activate it with your module in your admin area, it applies to all admin pages so it can break some of whmcs's standart javascripts and styles. If you want the hook only work for your own module, you should add a code like below for preventing your own codes to be applied in all admin area pages.
$moduleName = $_GET['module'];
if($moduleName == "yourmodulename"){
return $headoutput;
}
Regards,
Caner.
版权属于: 三三世界-百宝箱
本文链接: http://www.33f.net/linux/whmcs_headoutput.html
本文最后更新于2021年11月27日 ,已超过1108天没有更新,若内容或图片失效,请留言反馈。
本文允许转载,但请在转载时请以超链接或其它形式标明文章出处
@Doug Shume it's ok for me , you can post here.
Saved as a favorite, I like your website!
If some one wishes to be updated with hottest technologies after that he must be visit this site and be up to date daily.
Heello would you mind sharing which blog platform you're using? I'm planning to start my own blog in the near future but I'm having a tough time making a decision between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your layout seems different then moost blogs and I'm looking for something completely unique. P.S Apologies forr being off-topic butt I had to ask!
Thanks to my father who shared with me regarding this webpage, this website is genuinely amazing.
Hi, I have an overflow of customers that I'd like to send to you but I want to make sure you can handle more leads, let me know if you'd like me to send you more info.
zh.us.to 有效
kms.03k.org 有效
kms.chinancce.com
kms.shuax.com 有效
kms.dwhd.org 有效
kms.luody.info 有效
kms.digiboy.ir 有效
kms.lotro.cc 有效
www.zgbs.cc 有效
cy2617.jios.org 有效
@ 权限问题,试试sudo 再加命令。
你好提示Permission denied 怎么办啊