The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Too many domains in dropdown lists

Discussion in 'General Discussion' started by stevenc317, Feb 14, 2009.

  1. stevenc317

    stevenc317 Well-Known Member

    Joined:
    Jan 27, 2009
    Messages:
    56
    Likes Received:
    0
    Trophy Points:
    6
    My question to the Development Team via ticket# 379702:

    This isn't your normal tech support request, but if someone would kindly ask
    this question of the dev team for me?

    I am attempting to make some changes to the /frontend/x3/mail/pops.html
    template file to display the results more inline with how I do business.

    Mainly I am trying to modify the drop down box located at the top of the screen labeled: Managing (which lists all domains in system). I want to only display add-on domains, sub-domains, forwarding domains, parked domains. Or more accurately every domain *I* have added to the system, just not all the 'place holder/hostname' sites that cPanel adds when you add a domain:

    Example:

    If I am logged into my 'steven' virtual host in my 'coolstuff.net' hostname server, and I add a domain www.reallycoolsite.com. In the dropdown box I want to see reallycoolsite.com. Not reallycoolsite.steven.coolstuff.net.

    As I move all of my customers from my old server to this one, I will rapidly
    have hundreds of domains in each virtual host. I do not want my drop down lists to be so unmanageable they become useless.

    My Concept:
    To change the dropdown to list only the domains I want (as above) then have a check box next to (or below) the dropdown with a label of 'Show All' this would use simple javascript to repopulate the dropdown with the full list as it is today.

    My Question:
    Can the dev's either A) implement this feature across the system (any place
    there is the same dropdown box) as I suggested above. or B) can the devs tell me the internal variable names used for these various domains so that I may build my own dropdown box. Looking at the /frontend/x3/mail/managelist.html file I see there is a variable called listmaildomainsoptndef($FORM{'domain'}). What are the other ones for each (addon, sub, parked, redirect) so that I can load those each up into an array, sort alphabetically, then display in the box.

    Personally I would prefer the devs to implement this, as they can do it cleaner from within their main codes. If I have to do it via the templates it is going to be messy and sloppy coding.
     
  2. stevenc317

    stevenc317 Well-Known Member

    Joined:
    Jan 27, 2009
    Messages:
    56
    Likes Received:
    0
    Trophy Points:
    6
    Since this list has become a real pain in my butt, I took the liberty of making a javascript to clean the drop down list for me. Below are the codes, it should only take you a few seconds to drop this in without any issues.

    Step 1:
    Edit your managelist.html template file (in my case it is located in /usr/local/cpanel/base/frontend/x3/mail) -- you will need to access it via SSH using a command line text editor such as pico.​

    Step 2:
    Change line #2 and add 'name=domainlist1', it should now be
    HTML:
    <form name=domainlist1 method="GET" onChange="this.submit();">

    Step 3:
    edit your pops.html file (located in same directory) using pico, scroll down to the 2nd to last line (just before)
    HTML:
    <cpanel Branding="include(stdfooter.html)">
    
    and add the following codes

    HTML:
    <!-- You need to give the form element where the first dropdown list lives a name - call it domainlist1 -->
    <!-- Put the script below at the very end of the html template after the final div tag -->
    <!-- Replace HOSTNAME with the hostname of your server eg. hostname.net -->
    
    <!--------------------------->
    <!-- begin cleaning script -->
    <!--------------------------->
    
    <script language=javascript>
    var domainLength = document.domainlist1.domain.length;
    var allDomains = new Array();
    var pattern = /HOSTNAME/;
    for (var x=0; x<domainLength; x++)
    	{
    	var str = document.domainlist1.domain.options[x].value;
    	if (! str.match(pattern))
    		{
    		allDomains.push(str);
    		}
    	}
    newLength = allDomains.length;
    document.domainlist1.domain.length = newLength;
    for (var x=0; x<newLength; x++)
    	{
    	document.domainlist1.domain.options[x].text = allDomains[x];
    	}
    	
    for (var x=0; x<newLength; x++)
    	{
    	document.mainform.domain.options[x].text = allDomains[x];
    	}
    </script>
    
    <!------------------------->
    <!-- end cleaning script -->
    <!------------------------->
    

    NOTE: Make sure you change HOSTNAME to your server's hostname, this is what the RegEx uses to match in the string.
     
  3. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    I know for many this goes without saying, but just for some of the new folks that may stumble upon this thread: the x3 theme is periodically updated meaning such modifications may become overwritten.

    If you wish to preserve your changes rather than use updated files, you can create a shell script (/scripts/preupcp) to backup your modified file. Then create another shell script (/scripts/postupcp) to restore your modified file.
     
  4. stevenc317

    stevenc317 Well-Known Member

    Joined:
    Jan 27, 2009
    Messages:
    56
    Likes Received:
    0
    Trophy Points:
    6
    Thanks Dave, I have a backed up copy and just cp it over when I need to, but this will be much easier!

    thanks
     
Loading...

Share This Page