Hi guys,
What I am trying to do these days is showing sellected pictures into the widget "Latest photos" from Tidypics. I do the selection by check boxes which I put under each picture and also a "submit" button which after the selection of the pictures you want to be shown in the widget you should press the submit button and then the selected pictures should be shown in the widget. The check boxes and the submit button are wrapped around a form tags, where in the "action" atribute I passed the file "choosed_picture.php" in which is found the code for submitting the pictures to the Tidypics widget. My trouble is that I dont know which function I should use in order to "echo" the pictures in the widget after their selection. Till now I am using the value from the "name" atribute from the <name> tag of the check boxes with a "Post" method. And I am using the "$image_guid" as a value for the "value" atribute. Is it good idea to use "$image_guid" in order to distinguish one picture from another while echoing them in the widget?
The code that I changed is in:
1. mod\tidypics\views\default\object\image.php
79 <div class="tidypics_album_images">
80 <form action="choosed_pictures.php" method="post">
81 <a href="<?php echo $image->getURL();?>"><img src="<?php echo $vars['url'];? >pg/photos/thumbnail/<?php echo $image_guid;?>/small/" alt="<?php echo $image->title; ?>"/> </a>
82 <input type="checkbox" class ="products_checkbox" name="formPicture[]" value="<?php echo $image_guid;?>"/>
83 <input name="" type="submit" class="tidypics_products_selection" value="Save">
84 </form>
85 </div>
2. www\choosed_picture.php
<div class="contentWrapper">
<?php
//the number of files to display
$number = (int) $vars['entity']->num_display;
//if no number has been set, default to 6
if (!$number)
$number = 6;
$image_html = "<a href=\"{$vars['url']}pg/photos/download/{$image_guid}/inline/\" title=\"{$title}\" >";
echo '<div class="tidypics_widget_latest">';
<? foreach ($_POST['formPicture'] as $formPicture) { ?>
$image = $vars['entity'];
$image_guid = $image->getGUID();
$tags = $image->tags;
$title = $image->title;
$desc = $image->description;
$owner = $image->getOwnerEntity();
$friendlytime = friendly_time($image->time_created);
$image_html = "<a href="<?php echo $image->getURL();?>"><img src="<?php echo $vars['url'];?>"pg/photos/thumbnail/"<?php echo $image_guid;?>"/small/" "alt="<?php echo $image->title; ?>"/></a>";
echo $image_html;
<? } ?>
echo '</div>';
?>
</div>
Can some one give me a hint which function I should use in choosed_picture.php in order to echo/send the pictures in the widget?Am I near to the right way?
Thanks in advance!
All the best!
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
- ZoranM@zokipokii7
ZoranM - 0 likes
You must log in to post replies.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!