YOOtheme Pro is here! The best WordPress and Joomla theme. Learn more

Avatar koray.cokol asked

widgetkit2 and K2 featured filter

Hallo

I am trying to create a slideshow from my K2 categories, but I need to show only featred articles? I could not manage it? is it possible

  • Joomla
  • Widgetkit
  • Feature Request

3 Answers

2

Avatar alberto.santini answered

The only solution I've found, after working with the code, is to hack the type.php file to get an hard filter (unfortunately uneditable from admin) for the featured items.
I hope next widgetkit update will implement this kind of filter.

Simply I've changed the code of "type.php" to have the result you need.

I've inserted:

---------------  
                    $data    = array();  
                        $group   = isset($cats_group[$item->catid]) ? $cats_group[$item->catid] : 'default';  
                        $mapping = isset($content['mapping'][$group]) ? $content['mapping'][$group] : array();  

                        $data['title'] = $item->title;  
                         $data['featured'] = $item->featured; //***************** insert this at line 57  

                        $data['tags'] = array();  
---------------  

and

----------------  
                    if (isset($data['content']) && is_array($data['content'])) {  
                        $data['content'] = implode(', ', $data['content']);  
                    }  

                    if ($data['featured'] == 1) { //***************** insert this at line 85  

                    $items->add($data);  
                }  
                } //***************** insert this at line 89  
                return $items;  
            }  
-----------------

So the widget will receive data only from featured k2 items.

  • Note that if you need another widget with all data you have to duplicate the original widget without this code (copying and pasting dir inside widget plugins directory)

Edited

1

Avatar matthijs Support answered

For now this is not possible. Maybe this will be added in a later revision of the K2 plugin.

0

Avatar francis answered

Hi, thanks for post, that's what i was looking for.

Please, I need to use another not only featured widget, you say:

Note that if you need another widget with all data you have to duplicate the original widget without this code (copying and pasting dir inside widget plugins directory)

I've duplicated the content plugin and it works.

Now I have two content plugins, K2 (original) and K2 featured (copy), they are both working.

but the path to the file Type.php, in the new uses the same old, I do not know where to change.

Please, any help with this be welcome.

Thanks

Know someone who can answer? Share a link to this question via email or twitter.