Jump to content
Sign in to follow this  
rob2

how can i hide some fields ?

Recommended Posts

Hi,

 

user registering,new ordering,or client area data(editing) page,

 

i do not hope to show all the fields,just some fields,

 

is any way to make the setting or modify ?

 

 

thank you

Share this post


Link to post
Share on other sites

Hello,

 

Yes you should be able to make some fields optional under setup > general settings > other > Optional Client Profile Fields

 

You could then remove these fields from the form in the following:

 

/templates/your_template/clientregister.tpl

 

templates/orderforms/your_cart_template/viewcart.tpl

Share this post


Link to post
Share on other sites

ok,i will try it.

 

but it seems i can not modify the part as my attachment shows ?

 

 

thank you.

 

 

left (1).jpg

Share this post


Link to post
Share on other sites
but it seems i can not modify the part as my attachment shows ?

you'll need an action hook to edit that - they've been a few posted in the forums.

 

what exactly do you want to do with it - edit it in some way or remove it entirely?

Share this post


Link to post
Share on other sites

you can use the link below that i've given you before - it will work, but it's not perfect.

 

http://forum.whmcs.com/showthread.php?105295-Address-format-in-V6-02-Template-SIX&p=433838#post433838

 

i've modified it slightly for you - it will work and allow you to modify the order of the address elements to your own needs...

 

<?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;
               $address_new = $name."<p>".$address1.$address2.$postcode.$city.$state.$country."</p>";

       if (!is_null($primarySidebar->getChild('Client Details'))) {
                   $primarySidebar->removeChild('Client Details')
                                   ->addChild('Client Details')
                                   ->moveToFront()
                                   ->addChild($address_new);                
       }
});

it's still not the best way to do it - removing and adding a sidebar child! yuk!! :roll:

 

btw - the only reason i'm not describing the 'correct' way of how to do this, is because it's central to a project i'm working on... all will be revealed in the future! :idea:

Share this post


Link to post
Share on other sites
you can use the link below that i've given you before - it will work, but it's not perfect.

 

http://forum.whmcs.com/showthread.php?105295-Address-format-in-V6-02-Template-SIX&p=433838#post433838

 

i've modified it slightly for you - it will work and allow you to modify the order of the address elements to your own needs...

 

<?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;
               $address_new = $name."<p>".$address1.$address2.$postcode.$city.$state.$country."</p>";

       if (!is_null($primarySidebar->getChild('Client Details'))) {
                   $primarySidebar->removeChild('Client Details')
                                   ->addChild('Client Details')
                                   ->moveToFront()
                                   ->addChild($address_new);                
       }
});

it's still not the best way to do it - removing and adding a sidebar child! yuk!! :roll:

 

btw - the only reason i'm not describing the 'correct' way of how to do this, is because it's central to a project i'm working on... all will be revealed in the future! :idea:

 

may i ask if you lose " ?> " at end ?

Share this post


Link to post
Share on other sites
does it mean you will releae a plugin to edit it ?

in a way, yes - but that wouldn't be its core function... anyway, editing it easy as you can just modify the hook code, i'm working on taking it to another level! :idea:

 

may i ask if you lose " ?> " at end ?

you don't need them with hooks...

 

http://forum.whmcs.com/showthread.php?110991-moving-cron-directory-config-php-question&p=452467#post452467

 

We don't require the ?> file to user-modifiable files if possible. This is because it can often lead to problems if code, carriage returns or blank spaces are added afterwards.

Share this post


Link to post
Share on other sites

Hi,

 

the hook will remove the edit button,many i ask how can i keep the button here ?

Share this post


Link to post
Share on other sites
the hook will remove the edit button,many i ask how can i keep the button here ?

that's why I don't like the method he used, he's removing the sidebar and then re-creating it again.

 

what you'll need to do is add a footer to your new sidebar...

 

        $footer = '<a href="clientarea.php?action=details" class="btn btn-success btn-sm btn-block"><i class="fa fa-pencil"></i> '.Lang::trans('clientareaupdatebutton').'</a>';

                                   ->setFooterHtml($footer);

add the $footer variable after the $client variable line; and add the setFooter code after the addChild($address_new); line - remove the ; from that line, so that you only have one after this new setFooter line... that should work. :!:

Share this post


Link to post
Share on other sites

Hi,

 

do you mind help me correcting the following ?

 

 

<?php

use WHMCS\View\Menu\Item as MenuItem;

   add_hook('ClientAreaPrimarySidebar', 1, function (MenuItem $primarySidebar) 
       {
           $client = Menu::context('client');

           $footer = '<a href="clientarea.php?action=details" class="btn btn-success btn-sm btn-block"><i class="fa fa-pencil"></i> '.Lang::trans('clientareaupdatebutton').'</a>';

                                   ->setFooterHtml($footer);  

               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;
               $address_new = $name."<p>".$address1.$address2.$postcode.$city.$state.$country."</p>";

       if (!is_null($primarySidebar->getChild('Client Details'))) {
                   $primarySidebar->removeChild('Client Details')
                                   ->addChild('Client Details')
                                   ->moveToFront()
                                   ->addChild($address_new)
                                   ->setFooter($footer);
       }
});

Share this post


Link to post
Share on other sites

get rid of that first ->setFooterHtml($footer); before the if statement and it should work then.

Share this post


Link to post
Share on other sites

Hi,

 

i modify it as following but still get 500 error,may you help me check again ?

 

 

<?php

 

use WHMCS\View\Menu\Item as MenuItem;

 

add_hook('ClientAreaPrimarySidebar', 1, function (MenuItem $primarySidebar)

{

$client = Menu::context('client');

 

$footer = '<a href="clientarea.php?action=details" class="btn btn-success btn-sm btn-block"><i class="fa fa-pencil"></i> '.Lang::trans('clientareaupdatebutton').'</a>';

 

 

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;

$address_new = $name."<p>".$address1.$address2.$postcode.$city.$state.$country."</p>";

 

if (!is_null($primarySidebar->getChild('Client Details'))) {

$primarySidebar->removeChild('Client Details')

->addChild('Client Details')

->moveToFront()

->addChild($address_new)

->setFooter($footer);

}

});

Share this post


Link to post
Share on other sites

aagghhh... deleting and adding the same child... I can't look at that code anymore! :cry:

 

let's do it properly and you won't even have to mess with the footer... :idea:

 

<?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;
   $address_new = $name.'<p>'.$address1.$address2.$postcode.$city.$state.$country.'</p>';

   if (!is_null($primarySidebar->getChild('Client Details'))) {
                    $primarySidebar->getChild('Client Details')
                                              ->setBodyHtml($address_new);
   }
}); 

Share this post


Link to post
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.

Sign in to follow this  

  • 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