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
The best way to do it is by creating an edit.php for your widget, where the user can select images from tidypics. An array of image guids should be saved as a widget metadata (that's done automatically in edit.php form (check blog plugin for an example). In view.php for your widget, get your metadata with guids, iterate through your array and echo elgg_view_entity
Thanks Khayredinov. I will have a look at it and I'll let you know for the progress.
All the best!
Hi guys!
After several days I managed to do this. The only problem that I have now is that when I select any picture by the checkboxes it is not showing the chosen pictures. I dont know wheather I have made some mistake by saving it as a metadata in the database or something else is the problem. Any help is very welcommed.
edit.php :
<p>
<?php
echo elgg_echo("tidypics:widget:num_latest") . ": ";
if($vars['entity']->num_display == '') $vars['entity']->num_display = 6;
?>
<select name="params[num_display]">
<option value="6" <?php if($vars['entity']->num_display == 6) echo "SELECTED"; ?>>6</option>
<option value="9" <?php if($vars['entity']->num_display == 9) echo "SELECTED"; ?>>9</option>
<option value="12" <?php if($vars['entity']->num_display == 12) echo "SELECTED"; ?>>12</option>
<option value="15" <?php if($vars['entity']->num_display == 15) echo "SELECTED"; ?>>15</option>
<option value="18" <?php if($vars['entity']->num_display == 18) echo "SELECTED"; ?>>18</option>
</select>
</p>
<p>
<form action="tidypics/bestproductaction.php" method="post">
<?php
$pageowner_guid = page_owner();
//grab the user's pictures
$images = elgg_get_entities(array(
"type" => "object",
"subtype" => "image",
"owner_guids" => "$pageowner_guid",
"container_guid" => $guid,
"limit" => 3,
));
foreach ($images as $im){
echo "<div class='tidypics_album_cover'>";
echo elgg_view_entity($im);
echo "<input name='allImages[]' value='".$im->guid."' type='hidden' />";
echo "<input name='checkedImages[]' value='".$im->guid."' type='checkbox' />";
echo "</div>";
} ?>
<input type="submit"/>
</form>
</p>
view.php :
<div class="contentWrapper">
<div class="tidypics_widget_latest">
<div class="tidypics_line_break"></div>
<?php
//get the num of posts the user want to display
$number = (int) $vars['entity']->num_display;
//if no number has been set, default to 6
if (!$number){
$number = 6;
}
//grab the user's pictures
$pageowner_guid = page_owner();
$guid = $image->guid;
$title = $image->title;
echo elgg_view_title($title);
echo elgg_view('output/checkboxes', array($guid));
?>
</div>
</div>
bestproductaction.php :
<?php
$title = get_input('title');
$guid = $_POST['checkedImages'];
//create new image object
$image = new ElggObject();
$image->guid = $guid;
$image->subtype = "$bestProduct";
$image->title = $title;
$iamge->save();
?>
Thanks in advance for any help!
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.