Jump to content

Widget issues with Namecheap


Recommended Posts

Namecheap's API allows for grabbing info that can be displayed in WHMCs. I find it useful to have a list of expiring domains from there right on the admin homepage, so need to make a widget. Previously, I could do a foreach against the data returned from the call, and echo it all on the page. Worked fine. With upgrading to 5.2.8, I find I need to make a widget for this. I can get it to run and return data, but it will only display one domain (currently 8 are on that list) of the entire list. I know the data is accurate, because I can print_r on the command and see them all, but not within the widget block.


This works when not in a widget (truncated for this post, obviously):

foreach ($xml->CommandResponse->DomainGetListResult->Domain as $result)  {
echo "<strong><span id='smalltext'>".$result['Name'].": ".$result['Expires']."</span></strong><br />";

It would display this:

domain.com: 10/10/2013

domain2.com: 10/12/2013


Does anyone know how to get a similar result passed to the $content var in a widget? My meager PHP skills aren't cutting it.

Link to comment
Share on other sites

Figured it out.

Instantiate $content earlier in the script with $content =''; then have the lines like so:


foreach ($xml->CommandResponse->DomainGetListResult->Domain as $result)  {
$name = $result['Name'];
$expires = $result['Expires'];
$content .= "<strong><span id='smalltext'>".$name.": ".$expires."</span></strong><br />";

With that in the foreach, it shows them all. This could probably be cleaned up quite a bit, but as long as it's working, moving on.

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.

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