Welcome Guest, Not a member yet? Register   Sign In
Unable to add widget to widget area
#1

[eluser]CactusCoder[/eluser]
I've created a number of widgets for a web site I'm working on (my first one using PyroCMS) and in the process of doing so learned a lot about creating widgets - I'm getting really fast at it now :-)

But I just ran into a problem with the latest widget - when I try to drop it onto a widget area in admin, nothing happens - ie. the Add Widget Instance dialog doesn't appear.

I would appreciate help in figuring out what might cause this.

I tried removing the brackets from the label field - no difference.

Note: I inserted a space after the opening bracket of the img tag to keep the posting filter from messing with it...

Here is the widget code:
Code:
class Product_image_strip extends Widgets
{
    public $title = 'Product Image Strip';
    public $description = 'Show product image strip.';
    public $author = 'Terry Herckenrath';
    public $website = 'http://CactusCoder.com/';
    public $version = '1.0';
    
    public $fields = array(
        array(
            'field'   => 'type',
            'label'   => 'Type (featured,others)',
            'rules'   => 'required'
        )
    );
    
    public function __construct()
    {
        $this->load->helper('html');
    }

    public function run($options)
    {
        $output = '';

        // determine current collection
        $module = $this->uri->rsegment(1);
        
        if ($module == 'collections')
        {
            $this->load->model('products/products_m');
            $product = $this->products_m->get_by('p_slug', $this->uri->rsegment(3));
            $this->load->model('categories/categories_m');
            $collection = $this->categories_m->get($product->p_collection_id);
            
            switch ($options['type'])
            {
                case 'featured':
                    $title = '<span class="featured_in"> '.$collection->title.'</span>';
                    $products = $this->products_m->get_many_by("p_deleted = 0 AND (p_new = 1 OR p_on_sale = 1 OR p_clearance = 1)");
                    break;
                case 'others':
                    $title = 'Other pieces in this collection:';
                    $products = $this->products_m->random(6, "p_deleted = 0 AND (p_parent_collection_id = {$collection->id} OR p_collection_id = {$collection->id}");
                    break;
                default:
                    $title = 'ERROR: Please fix Product Image Strip Type setting';
                    break;
            }
            
            // build image strip
            $image_count = 0;
            foreach ($products as $product)
            {
                // up to 6 images per row
                if ($image_count > 5)
                {
                    $output .= '<br />';
                    $image_count = 0;
                }
                
                $output .= "< img src='/img/prod/t1/{$product->p_slug}' alt='{$product->p_title}' title='{$product->p_title}' />";
                $image_count++;
            }
            
            $output = "<div>{$output}</div>";
        }
        
        return $output;
    }
    
}
#2

[eluser]CactusCoder[/eluser]
Still no idea what is causing this, but my work-around solution was to manually add the appropriate rows to the widget_instances_table...
#3

[eluser]danmontgomery[/eluser]
You would probably have better luck on the pyrocms forums




Theme © iAndrew 2016 - Forum software by © MyBB