sactobob Posted September 24, 2020 Share Posted September 24, 2020 I'd like to override the following admin language: $_ADMINLANG['addons']['customname'] = "Custom Name"; However, I don't want this override to be for every addon product. Only if a specific addon is displayed. IE, I have an addon called "email address". So if the addon email address is being displayed then: $_ADMINLANG['addons']['customname'] = "Email Address"; I have the lang/overrides/english.php created. Since this is a php file are there variables exposed that would allow me to check this and override only for a specific addon? Or do I create a page specific for the addon that is displayed both on the admin side and the client side? Any help point to docs or a how-to would be appreciated. Thank you, -Bob 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted September 25, 2020 Share Posted September 25, 2020 21 hours ago, sactobob said: I have the lang/overrides/english.php created. I hope you mean /admin/lang/overrides/english.php - because if you're using the overrides files in the main /lang/ folder, then they are just for the client area. 21 hours ago, sactobob said: Since this is a php file are there variables exposed that would allow me to check this and override only for a specific addon? I suspect you'd have to code it with a hook - you couldn't make a selective override just by specifying it in a language file. 21 hours ago, sactobob said: Or do I create a page specific for the addon that is displayed both on the admin side and the client side? what exactly are you wanting to do - just change the "Custom Name" field heading on the clientsservices.php admin area product addon page or is there something that needs changing in the client area too ? 0 Quote Link to comment Share on other sites More sharing options...
sactobob Posted September 25, 2020 Author Share Posted September 25, 2020 Quote I hope you mean /admin/lang/overrides/english.php - because if you're using the overrides files in the main /lang/ folder, then they are just for the client area. Yes, I'm using the admin/lang/overrides folder. Quote I suspect you'd have to code it with a hook - you couldn't make a selective override just by specifying it in a language file. Got it. I was hoping since that's a php file that there was some internal variable exposed to php that identified what page/addon I was on and would selectively change it like that. And yes, only want to change the field name, as I'm using that field for the email address field of the addon rather then creating another custom field. Plus when there's an email in that field it displays nicely on the admin/client page that identifies the service and the email address. I guess it could be a matter of training the people that have access to the admin area, but would rather identify the field properly.. Hook it is.. Thanks for the reply. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted September 26, 2020 Share Posted September 26, 2020 Hi Bob, 15 hours ago, sactobob said: Got it. I was hoping since that's a php file that there was some internal variable exposed to php that identified what page/addon I was on and would selectively change it like that. sadly not. 15 hours ago, sactobob said: And yes, only want to change the field name, as I'm using that field for the email address field of the addon rather then creating another custom field. personally, i'd probably just use an override to change the value to "Custom Name / Email Address" - but that's just me being lazy at the weekend. 🙂 17 hours ago, sactobob said: I guess it could be a matter of training the people that have access to the admin area, but would rather identify the field properly.. Hook it is.. in terms of hooking, you'll be able to get the aid value from the URL - that value will be the ID value from the tblhostingaddons database table and then you'd need to get the 'addonid' value for that row (that addonid value relates to the ID value in tbladdons)... basically, it's these values that you need to check to confirm whether the current addon is one of your "email" product addons... and only once you know that, could you consider changing the field value. as a hook, it would be along the lines of... <?php # Change Field Label Based on Product Addon # Written by brian! use WHMCS\Database\Capsule; function admin_product_addon_change_field_label_hook($vars) { if ($vars['filename'] == 'clientsservices' && isset($_GET["aid"])) { $addonid = Capsule::table('tblhostingaddons')->where('id',$_GET["aid"])->value('addonid'); $validaddons = array(1,2); if (in_array($addonid,$validaddons)) { return "<script> $('td').filter(function(){ return $(this).text().indexOf('".AdminLang::trans('addons.customname')."') > -1; }).text('".AdminLang::trans('fields.email')."'); </script>"; } } } add_hook("AdminAreaFooterOutput", 1, "admin_product_addon_change_field_label_hook"); the only line that you should need to change would be the values within the $validaddons array - this is a list of addon IDs of your "email address" addons - those values can be obtained from the ID values in the URL when you edit them via setup->product/services->product addons or from the database. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.