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
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!
ZoranM,
Elgg uses mod_rewrite and there is often no association between a URL and a file system path.
In this case, TidyPics images are stored in Elgg's data directory.
By the way, rewriting parts of TidyPics is a Bad Idea. TidyPics is updated from time to time and if you rewrite parts of the code you will not be able to upgrade.
Much, much better to learn Elgg's plugin system and write a small plugin to over-ride the bits of TidyPics you want to change.
Thanks guys,
I found where the pictures were stored, as Kevin sugested. I knew that all files from Elgg are stored in the Elgg data directory, but I could not connect the dots between the file path that was created by the script and knowing that the files are in Elgg data directory. Now is fine, thanks again to both. I am planning to wirte a plugin related to Tidypics but only because of time constrains for the task that I am working on I can not do that right now.
All the best!
I'm afraid there are more changes necessary to get the current tidypics version working in Elgg 1.8 then. The settings you make in the admin section are not saved in a file but in the Elgg database. I don't know if it would be good to change the settings in the database directly though. In the worst case you will damage your whole site, if some options of tidypics are not compatible with Elgg 1.8.
I know it's not a satisfying advice, but I would advice you to wait for an official release of an Elgg 1.8 compatible version of tidypics. There's a development version for Elgg 1.8 available at http://code.google.com/p/tidypics/. But I haven't tested it for months, so I don't know if it currently works or not (or if it is even the most recent development version).
It has been said that there will be an Elgg 1.8 compatible version of tidypics after Elgg 1.8.1 has been released. Though this could still take a while (maybe several weeks until Elgg 1.8.1 and who knows how much longer then until a new tidypics).
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.