Hi to all,
I am trying to develope a widget for Tidypics and I am in arealy big trouble. Can someone help me?I did not know that it is going to be so complicated. I have a form and the "name" atribute I stored it in a params[] array.In this array are stored the "guid" from every checked picture.
"<input value='checkedImage' name='params[".$im->guid."]' type='checkbox' />";
Now when I want to get this guid's, please excuse me if I make mistakes because I am a novice, I can not because they are stored in the database as numbers and the way to acces them is by using vars[entity]->123, or vars[entity]->324 and etc. But vars[] does not allow direct access of variables. Can someone help me? I need any posible way how to get the guid's stored in params[] array into another array. Is there any function or anything else?
I tried by $vars['entity'] ->guid, $vars['entity'] ->getGUID, $vars['entity'] ->owner_guid;
but non of them are in fact the guid's of the pictures that I have checked, but the value that I get is the widget guid.
If there is any topic in elgg regarding this please also reference me to it.
Thanks to all!
Thanks
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.
- ihayredinov@ihayredinov
ihayredinov - 0 likes
- ZoranM@zokipokii7
ZoranM - 0 likes
- ihayredinov@ihayredinov
ihayredinov - 0 likes
- ZoranM@zokipokii7
ZoranM - 0 likes
- ihayredinov@ihayredinov
ihayredinov - 0 likes
You must log in to post replies.name="params['checkedImage']"
$vars['entity']->checkedImage is your widget's metadata that stores an array of selected guids.
Hi Khayredinov,
I tried the way as you sugested, but it did not worked.The $vars['entity']->checkedImage was alwas giving back an empty array. So what I did it in another way:
1. I kept the form structure as it was in edit.php :
echo "<tr><td>";
echo elgg_view_entity($im);
echo "</td><td>";
echo "<input value='checkedImage' name='params[".$im->guid."]' type='checkbox' />";
echo "</td></tr>";
2. I got the checked images guid in this way:
$filtered_psettings = 0;
$entity = $vars['entity'];
$psettings = get_all_private_settings($entity->guid);
$filtered_psettings = array_keys($psettings, "checkedImage");
$product_guids = array_values($filtered_psettings);
And I have now all the guids from the cehcked images in $product_guids but when I want to pass them to:
$images = elgg_get_entities(array(
"type" => "object",
"subtype" => "image",
"owner_guids" => $product_guids,
//"container_guid" => $guid,
"limit" => ELGG_ENTITIES_NO_VALUE,
));
and than in order to display them I use:
foreach ($images as $im){
the echo elgg_view_entity($im);
}
It is not returning anything. Even when I do var_dump($images->owner_guids); it is returning NULL.
Do you have any suggestion why it is like this, why Elgg is reacting in this way?
All best!
I don't understand why are you using your image_guid array for owner_guids...
foreach ($product_guids as $im) {
elgg_view_entity($im);
}
You don't need to get an array of entities to display them.
Thanks again for the help Khayredinov! I tried as you sugested. It did not worked eather. I realy dont understand how this whole thing works, or it is supposed to work. Here is again what I did :
<?php
$guid = (int) get_input('guid');
$filtered_psettings = 0;
$entity = $vars['entity'];
$psettings = get_all_private_settings($entity->guid);
$filtered_psettings = array_keys($psettings, "checkedImage");
$product_guids = array_values($filtered_psettings);
foreach ($product_guids as $im){
echo elgg_view_entity($im);
}
?>
At the end it returns "boolean false" which it seams that the values in $product_guid array are not an "instanceof ElggEntity". This are only the guids. But should the guids be an instance of ElggEntity? Sorry this might sound stupid question, but I am still trying to learn. Thanks for the help in advance!
What is the first place to look for an answer? Tidypics plugin:
1. tidypics/views/default/widgets/latest_photos
line 11: tp_get_latest_photos
2. tidypics/lib/tidypics
line 36: tp_list_entities
line 172: tp_view_entity_list
line 178: $html = elgg_view('tidypics/gallery',array(
'entities' => $entities,
'count' => $count,
'offset' => $offset,
'limit' => $limit,
'baseurl' => $_SERVER['REQUEST_URI'],
'fullview' => $fullview,
'context' => $context,
'viewtypetoggle' => $viewtypetoggle,
'viewtype' => get_input('search_viewtype','list'),
'pagination' => $pagination
));
So pass your entity list to the elgg_view('tidypics/gallery') and see what happens