Jump to content

widget out of place


monstertocode

Recommended Posts

Hi everyone i was trying for the first time making a widget and well this is what i got out of it,

the client file widget is "put" in another widgets div.

i have been checking the templates(standard admin homepage.tpl didn't touch it) and the code for a while now and i at least didn't found any errors (pretty new to this).

I literally copy pasted what was in the create widget section.

Thank you.

Untitled5.png

Untitled6.png

Link to comment
Share on other sites

54 minutes ago, monstertocode said:

the client file widget is "put" in another widgets div.

going from that screenshot, I think it's outside of the widgets div entirely.

26 minutes ago, monstertocode said:

I literally copy pasted what was in the create widget section.

seriously - what's the point of pasting an image of the code you used? why not just copy&paste the code into the post... that makes it easier to copy and test the code locally... i'm not going to spend my time manually typing in your code from scratch. 9_9

using the code in the documentation as a starting point, and tweaking it to match your changes, it works fine and is located correctly within the v7.4.1 admin homepage.

https://developers.whmcs.com/addon-modules/admin-dashboard-widgets/

6CyVJmr.png

57 minutes ago, monstertocode said:

I literally copy pasted what was in the create widget section.

so when you used the above hello world widget, it was in the correct place - or outside it as above??

i'd suggest deleting your widget file, using the Hello world widget and then see where it is displayed... then change it one line at a time.

Link to comment
Share on other sites

hi i wanna say thank you for the quick reply and here is the code i'm using.

In the first picture that i sent before and look at the developper's tool you can see that the div with id="panelClientFiles" is in the other div that as the id="panelActivity" but yes it shows outside.

When i used the hello world widget (before changing a little) it was not correctly placed it was at that place the whole time.

<?php

use WHMCS\Database\Capsule;

add_hook('AdminHomeWidgets', 1, function()
{
    return new ClientFiles();
});

/**
 * Hello World Widget.
 */
class ClientFiles extends WHMCS\Module\AbstractWidget
{
    protected $title = 'Client Files';
    protected $description = '';
    protected $weight = 100;
    protected $columns = 1;
    protected $cache = false;
    protected $cacheExpiry = 120;
    protected $requiredPermission = '';
    
    public function getData()
    {
        return array();
    }

    public function generateOutput($data)
    { 
        //just for testing (going to change soon)
        $content = '';
        
        foreach (Capsule::table('tblclients')->get() as $client) 
        {
            $content .= $client->firstname . "<br />";
        }
        
        $html = <<<EOF
    <div class="widget-content-padded">
        {$content}
    </div>
EOF;
        
    return $html;
    }
}

i copied pasted the hello word widget again that one i didn't change anything it is located in the "modules/widgets" folder with the name HelloWorld.php

Untitled79.png

Link to comment
Share on other sites

there's nothing obviously wrong with the widget code that would cause this - if I use your widget code in a v7.4.1 dev, it works fine and is shown amongst the other widgets...

image.thumb.png.d2dd5bf09a221f528dd736073749b39f.png

my first thought as to the cause would be some dodgy code in a previous widget, but it looks like the others are all default widgets supplied with WHMCS.

therefore, I think there is an issue with your dev installation - you could try reuploading the 'vendor' and 'includes' folders and see if that fixes it... you could also try uploading the blend template again (or try v4 and see if it does the same with that).

failing that, you may need to open a ticket with support and let them take a closer look at your dev.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • 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