Jump to content

Override language based on Add-on Product Displayed


Recommended Posts

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

Link to comment
Share on other sites

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 ?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

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