Bertie Posted July 5, 2017 Share Posted July 5, 2017 Hi all, We have created a 'Custom Client Field' which works great and shows up on the "Profile" section of any of the clients. But we would like this specific field to show up on the Client Summary page. On the Clients Information section if possible just under the phone number. What is the best way of doing that if it's possible? Any help will be appreciated. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted July 5, 2017 Share Posted July 5, 2017 We have created a 'Custom Client Field' which works great and shows up on the "Profile" section of any of the clients. But we would like this specific field to show up on the Client Summary page. On the Clients Information section if possible just under the phone number.What is the best way of doing that if it's possible? you're in luck - that's one of the few admin pages that uses a template (/admin/templates/blend (or v4)/clientsummary.tpl), so there's no need for an action hook as the profile page already has the custom field information you want... <tr><td>{$_ADMINLANG.fields.phonenumber}</td><td>{$clientsdetails.phonenumber}</td></tr> <tr><td>Custom Field</td><td>{$clientsdetails.customfields1}</td></tr> you might need to throw a {debug} into the template code to find out the specific name of the $clientsdetails variable to use (it's going to be customfieldsX where X is a number), but I think if you only have 1 client custom field, the above should work. 1 Quote Link to comment Share on other sites More sharing options...
Bertie Posted July 5, 2017 Author Share Posted July 5, 2017 you're in luck - that's one of the few admin pages that uses a template (/admin/templates/blend (or v4)/clientsummary.tpl), so there's no need for an action hook as the profile page already has the custom field information you want... <tr><td>{$_ADMINLANG.fields.phonenumber}</td><td>{$clientsdetails.phonenumber}</td></tr> <tr><td>Custom Field</td><td>{$clientsdetails.customfields1}</td></tr> you might need to throw a {debug} into the template code to find out the specific name of the $clientsdetails variable to use (it's going to be customfieldsX where X is a number), but I think if you only have 1 client custom field, the above should work. Thanks, managed to get it working. Is there a way to get that said custom field on the client area but not allowed to be edited by the client? I know the taking the tick out of "admin only" would allow it display on the clients view. But then this field becomes editable by them. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted July 5, 2017 Share Posted July 5, 2017 Is there a way to get that said custom field on the client area but not allowed to be edited by the client? I know the taking the tick out of "admin only" would allow it display on the clients view. But then this field becomes editable by them. as you say, you could untick the "admin only" checkbox and then in clientareadetails.tpl, change... {if $customfields} {foreach from=$customfields key=num item=customfield} <div class="form-group"> <label class="control-label" for="customfield{$customfield.id}">{$customfield.name}</label> <div class="control"> {$customfield.input} {$customfield.description} </div> </div> {/foreach} {/if} to... {if $customfields} {foreach from=$customfields key=num item=customfield} <div class="form-group"> <label class="control-label" for="customfield{$customfield.id}">{$customfield.name}</label> <div class="control"> {$customfield.value} {$customfield.description} </div> </div> {/foreach} {/if} basically, you're just changing $customfield.input to $customfield.value - and that, as the code suggests, just displays the current content of the customfields and doesn't provide the user with an option to edit them.... though you may need to adjust the layout to suit the output. 0 Quote Link to comment Share on other sites More sharing options...
Bertie Posted July 5, 2017 Author Share Posted July 5, 2017 Thanks Brian, that has worked as well. Much appreciated! 0 Quote Link to comment Share on other sites More sharing options...
Bertie Posted September 20, 2017 Author Share Posted September 20, 2017 Is there a way to edit the "Your Info" box on the clients area to add their client ID? Would be handy to be able to display their client ID on the main page when they are logged in. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted September 20, 2017 Share Posted September 20, 2017 Is there a way to edit the "Your Info" box on the clients area to add their client ID? Would be handy to be able to display their client ID on the main page when they are logged in. you'd have to use an action hook - similar to the one I posted here... and then adjust for wherever you want to add the ID number. <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimarySidebar', 1, function (MenuItem $primarySidebar) { $client = Menu::context('client'); if($client->companyname != ""){ $name = '<strong>'.$client->companyname.'</strong>'; } else { $name = '<strong>'.$client->fullname.'</strong>'; } $address1 = $client->address1; if($client->address2 != ""){ $address2 = '<br>'.$client->address2; } else { $address2=''; } $city = ' '.$client->city; $state = '<br>'.$client->state; $postcode = '<br>'.$client->postcode; $country = '<br>'.$client->countryname; $clientid = '<br>Client Number: '.$client->id; $address_new = $name.'<p>'.$address1.$address2.$postcode.$city.$state.$country.$clientid.'</p>'; if (!is_null($primarySidebar->getChild('Client Details'))) { $primarySidebar->getChild('Client Details') ->setBodyHtml($address_new); } }); 0 Quote Link to comment Share on other sites More sharing options...
Bertie Posted September 20, 2017 Author Share Posted September 20, 2017 (edited) you'd have to use an action hook - similar to the one I posted here... and then adjust for wherever you want to add the ID number. <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimarySidebar', 1, function (MenuItem $primarySidebar) { $client = Menu::context('client'); if($client->companyname != ""){ $name = '<strong>'.$client->companyname.'</strong>'; } else { $name = '<strong>'.$client->fullname.'</strong>'; } $address1 = $client->address1; if($client->address2 != ""){ $address2 = '<br>'.$client->address2; } else { $address2=''; } $city = ' '.$client->city; $state = '<br>'.$client->state; $postcode = '<br>'.$client->postcode; $country = '<br>'.$client->countryname; $clientid = '<br>Client Number: '.$client->id; $address_new = $name.'<p>'.$address1.$address2.$postcode.$city.$state.$country.$clientid.'</p>'; if (!is_null($primarySidebar->getChild('Client Details'))) { $primarySidebar->getChild('Client Details') ->setBodyHtml($address_new); } }); Hi, Thanks for that - It works but for some reason the clients full name has now vanished? It's just left the company name, address and the client number. Also there is a gap between the postcode/state line and the country. So now there's a bit of a white gap after the state and then it shows the country. Edited September 20, 2017 by Bertie 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted September 20, 2017 Share Posted September 20, 2017 Thanks for that - It works but for some reason the clients full name has now vanished? It's just left the company name, address and the client number. Also there is a gap between the postcode/state line and the country. So now there's a bit of a white gap after the state and then it shows the country. to get the client's name back... <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimarySidebar', 1, function (MenuItem $primarySidebar) { $client = Menu::context('client'); if($client->companyname != ""){ $name = '<strong>'.$client->companyname.'</strong><br><i>'.$client->fullname.'</i>'; } else { $name = '<strong>'.$client->fullname.'</strong>'; } $address1 = $client->address1; if($client->address2 != ""){ $address2 = '<br>'.$client->address2; } else { $address2=''; } $city = '<br>'.$client->city; $state = ', '.$client->state; $postcode = ', '.$client->postcode; $country = '<br>'.$client->countryname; $clientid = '<br>Client Number: '.$client->id; $address_new = $name.'<p>'.$address1.$address2.$city.$state.$postcode.$country.$clientid.'</p>'; if (!is_null($primarySidebar->getChild('Client Details'))) { $primarySidebar->getChild('Client Details') ->setBodyHtml($address_new); } }); to modify the rest is just a case of changing the output and/or it's order... it should look fairly similar to the default output now though. 0 Quote Link to comment Share on other sites More sharing options...
Bertie Posted September 21, 2017 Author Share Posted September 21, 2017 to get the client's name back... <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimarySidebar', 1, function (MenuItem $primarySidebar) { $client = Menu::context('client'); if($client->companyname != ""){ $name = '<strong>'.$client->companyname.'</strong><br><i>'.$client->fullname.'</i>'; } else { $name = '<strong>'.$client->fullname.'</strong>'; } $address1 = $client->address1; if($client->address2 != ""){ $address2 = '<br>'.$client->address2; } else { $address2=''; } $city = '<br>'.$client->city; $state = ', '.$client->state; $postcode = ', '.$client->postcode; $country = '<br>'.$client->countryname; $clientid = '<br>Client Number: '.$client->id; $address_new = $name.'<p>'.$address1.$address2.$city.$state.$postcode.$country.$clientid.'</p>'; if (!is_null($primarySidebar->getChild('Client Details'))) { $primarySidebar->getChild('Client Details') ->setBodyHtml($address_new); } }); to modify the rest is just a case of changing the output and/or it's order... it should look fairly similar to the default output now though. Hi Brian, Thank you very much - Works great! 0 Quote Link to comment Share on other sites More sharing options...
Bertie Posted September 21, 2017 Author Share Posted September 21, 2017 as you say, you could untick the "admin only" checkbox and then in clientareadetails.tpl, change... {if $customfields} {foreach from=$customfields key=num item=customfield} <div class="form-group"> <label class="control-label" for="customfield{$customfield.id}">{$customfield.name}</label> <div class="control"> {$customfield.input} {$customfield.description} </div> </div> {/foreach} {/if} to... {if $customfields} {foreach from=$customfields key=num item=customfield} <div class="form-group"> <label class="control-label" for="customfield{$customfield.id}">{$customfield.name}</label> <div class="control"> {$customfield.value} {$customfield.description} </div> </div> {/foreach} {/if} basically, you're just changing $customfield.input to $customfield.value - and that, as the code suggests, just displays the current content of the customfields and doesn't provide the user with an option to edit them.... though you may need to adjust the layout to suit the output. Just trying to adjust this if possible - Basically added another custom field for a mobile number as WHMCS only allow 1 phone number. But with the said code being used, it won't allow the user to be able to edit the mobile number custom field due to the other custom field being non-editable by the client. If someone could put me in the right direction that would be fantastic. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted September 21, 2017 Share Posted September 21, 2017 Just trying to adjust this if possible - Basically added another custom field for a mobile number as WHMCS only allow 1 phone number. But with the said code being used, it won't allow the user to be able to edit the mobile number custom field due to the other custom field being non-editable by the client. If someone could put me in the right direction that would be fantastic. then you'll need to get the customfield id value for the mobile phone cf and alter the line... {$customfield.value} {$customfield.description} to... {if $customfield.id eq '1'}{$customfield.input}{else}{$customfield.value}{/if} {$customfield.description} just change the value of '1' to whatever the id value is for your mobile field and that should be editable, the rest should be readonly. 0 Quote Link to comment Share on other sites More sharing options...
Bertie Posted September 22, 2017 Author Share Posted September 22, 2017 then you'll need to get the customfield id value for the mobile phone cf and alter the line... {$customfield.value} {$customfield.description} to... {if $customfield.id eq '1'}{$customfield.input}{else}{$customfield.value}{/if} {$customfield.description} just change the value of '1' to whatever the id value is for your mobile field and that should be editable, the rest should be readonly. Thanks, that works a treat. Thanks again for all of the help with this. 0 Quote Link to comment Share on other sites More sharing options...
Bertie Posted October 10, 2017 Author Share Posted October 10, 2017 Just noticed this with a client changing their details themselves. The field that can't be edited by them, when they make changes to any of the other fields - It actually wipes the uneditable field from both the client view/admin panel - Is there a way to stop that? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 10, 2017 Share Posted October 10, 2017 using which WHMCS version ? 0 Quote Link to comment Share on other sites More sharing options...
Bertie Posted October 10, 2017 Author Share Posted October 10, 2017 7 minutes ago, brian! said: using which WHMCS version ? 7.3.0 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 10, 2017 Share Posted October 10, 2017 2 hours ago, Bertie said: Just noticed this with a client changing their details themselves. The field that can't be edited by them, when they make changes to any of the other fields - It actually wipes the uneditable field from both the client view/admin panel - Is there a way to stop that? i've just tested this on a v7.3 dev... you're right...damn v7.3... https://youtu.be/sPbjPOgRtyA so i'd forget about using $customfield.value... On 9/22/2017 at 8:42 AM, Bertie said: {if $customfield.id eq '1'}{$customfield.input}{else}{$customfield.value}{/if} {$customfield.description} and try this instead... {if $customfield.id eq '1'}{$customfield.input}{else}{$customfield.input|replace:'>':' readonly>'}{/if} {$customfield.description} i've tested this locally, CF#1 would be editable and any other CF will be readonly - the readonly customfields are no longer losing their values when other fields are updated... 0 Quote Link to comment Share on other sites More sharing options...
Bertie Posted October 11, 2017 Author Share Posted October 11, 2017 15 hours ago, brian! said: i've just tested this on a v7.3 dev... you're right...damn v7.3... https://youtu.be/sPbjPOgRtyA so i'd forget about using $customfield.value... and try this instead... {if $customfield.id eq '1'}{$customfield.input}{else}{$customfield.input|replace:'>':' readonly>'}{/if} {$customfield.description} i've tested this locally, CF#1 would be editable and any other CF will be readonly - the readonly customfields are no longer losing their values when other fields are updated... Yep, that works great - Thanks again. 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.