Hello everybody I'm writing a new plugin with a sidebar layout in which I will implement a tag and name search. I have studied members plugin search system in order to understand how it works. Right now I have implemented a tag search plugin but it doesn't seem to work and I have no idea why. This is how search works:
<?php
/**
* Pagina di ricerca
*
*/($vars['search_type'] == 'tag') {
$tag = get_input('tag');$title = elgg_echo('Ricerca prodotti per tags', array($tag));
$options = array();
$options['query'] = $tag;
$options['type'] = "gestore";
$options['offset'] = $offset;
$options['limit'] = $limit;
$results = elgg_trigger_plugin_hook('search', 'tags', $options, array());
$count = $results['count'];
$gestore = $results['entities'];
$content = elgg_view_entity_list($gestore, array(
'count' => $count,
'offset' => $offset,
'limit' => $limit,
'full_view' => false,
'list_type_toggle' => false,
'pagination' => true,
));
}$params = array(
'title' => $title,
'content' => $content,
'sidebar' => elgg_view('gestore_prodotti/sidebar'),
);$body = elgg_view_layout('one_sidebar', $params);
echo elgg_view_page($title, $body);
It displays results but it doesn't consider tags search. I studied database documentation in order to understand how it works. This is how I create the object in my plugin save.php file:
$gestore = new ElggObject();
$gestore->subtype = "gestore_prodotti";
$gestore->title = $title;
$gestore->image = $image;
$gestore->option = $option;
$gestore->description = $body;
I have some doubts about this too because I can't figure "gestore" inside elgg object database. Why?
Thanks in advance
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by Raül Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- Jon Dron@jondron

Jon Dron - 0 likes
- Matt Beckett@Beck24

Matt Beckett - 0 likes
- Andrea Cesaro@ea1987

Andrea Cesaro - 0 likes
- Matt Beckett@Beck24

Matt Beckett - 0 likes
- Andrea Cesaro@ea1987

Andrea Cesaro - 0 likes
- Andrea Cesaro@ea1987

Andrea Cesaro - 0 likes
You must log in to post replies.I struggled a bit with a broadly similar problem - see my plugin at http://community.elgg.org/plugins/1524958/1.01/au-group-tag-menu for one possible and simple way of doing this. It's designed only for groups and pre-specified tags rather than a freeform search, but the general principle might work for your system. I created my own page to present the results rather than hooking into search because the search interface itself is a bit confusing, always taking you out of the context you are in and breaking the flow.
In your options:
'type' should be 'object'
'subtype' should be 'gestore_prodotti'
Also for search you need to make sure it's registered
http://reference.elgg.org/entities_8php.html#ade3d136ebb672909d60d6e3f10095818
Thanks for your answers. I was realizing today that I made some mistakes with type (according to tutorials/blog and this guide: http://docs.elgg.org/wiki/Engine/DataModel/Entities
Now i have tested and it works using this option:
For search I'm reading readme.txt in search and as Matt suggested me, this file says:
To appear in search you must register your entity type and subtype
by saying in your plugin's init function:
register_entity_type($type, $subtype);
I have inserted this code in start.php:
But it doesn't effect on tag search.
I have a question about type and object... I'm looking at elgg database, according to what I'm reading on documentation I can see entity-object table with blogs, bookmarks.. Right now I have created a newelggobject of type object and subtype gestore_prodotti. Where I can see this subtype in elgg_objects_entity table?
Thanks for your support guys!
For 1.8 the function is elgg_register_entity_type()
Also make sure both the type and subtype are in quotes, otherise php may consider that a constant which resolves to null (which is probably why your search isn't working)
New objects should be new rows in the objects_entity table
Thanks for suggestions Matt. I tranformed code into
But search doesn't work anyway. I have checked again in objects_entity table and there is no trace of a object rows (or gestore_prodotti row?).
Sorry Matt, rows are there.. but search doesn't work. Right now I have corrected search like this: