This is for discussion only purpose with others devs
- DO NOT MAKE ANY CHANGES OF OSSN CORE COMPONENTS.
Feedback of users from my site: Users of my site are deleting album photo by accident, because they confuse the delete button, thinking it is the submit button, even though it clearly says delete and its red.
There is no popup warning about this, so clicking the button immediately deletes the photo without prompting.
Here are experimental fix to prevent that:
Replace the line with this:
<li><a href="<?php echo ossn_site_url("action/photo/delete?id={$params->guid}", true);?>" data-ossn-msg="<?php echo ossn_print('delete:photoconfirm');?>" class="ossn-make-sure badge bg-danger"><i style="margin-right:0;" class="fa fa-trash"></i></a></li>
In ossn.en.php locale file (components/OssnPhotos/locale) L33 add this:
'delete:photoconfirm' => 'Are you sure?',
So now, when clicking the little red button with font awesome icon, will it display a popup window asking to confirm the action.
Next possible step?, trying to move the button where are the other buttons (back to album button) etc. but i dont know how to do this.
Feel free to comment to improve the experience of real users :)
Hugo,
you're wondering why
<a class="button-grey ossn-make-sure" href="<?php echo ossn_site_url("action/photo/delete?id={$params->guid}", true);?>"> <?php echo ossn_print('delete:photo'); ?> </a>
does not work in this location.
Ok, first rule of thumb: NEVER use a line of code with vars included you're not sure about their meaning.
$params is used throughout Ossn in thousends of places and may be completely different every time.
In this case there's in fact no $params->guid, that's why your button doesn't work.
So what to use instead? To get an idea, simply log $params to your error_log file with a line like
error_log('PHOTO VIEW PARAMS ' . ossn_dump($params));
right in the beginning of the view.php file. And you'll find the photo id to be used for deleting two times. So you have the choice to address it either like
id={$params['photo']}
or from inside the OssnPhotos Object like
id={$params['entity']->guid}
So far for the first step = getting a working delete button at all. ;)
@Arsalan Thanks Arsalan! Also profile and cover photos needs warning prompt.
@Michael Yes Michael, you right ossn-make sure
does the job. Thanks!
I'm trying to replicate the "Delete album" button for the photos pages, but can't manage to get working.
to
Sure if add this line:
<a class="button-grey ossn-make-sure" href="<?php echo ossn_site_url("action/photo/delete?id={$params->guid}", true);?>"> <?php echo ossn_print('delete:photo'); ?> </a>
To:
components > OssnPhotos > plugins > default > photos > pages > photo > view.php
It will display but will not work, also it will displayed for non-owner users (Also i tried adding a if (ossn_isLoggedIn())
but nope.
I think i need to dig in ossn_com.php of OssnPhotos component to add a function similar to this ?
Ideas welcomed :)
Yes, good idea!
You can achieve it this way:
<li><a class="btn btn-danger ossn-make-sure" href="<?php echo ossn_site_url("action/photo/delete?id={$params->guid}", true); ?>"><i class="fa fa-trash"></i><?php echo ossn_print('delete:photo'); ?> </a></li>
"Are you sure?" is Ossn's default question whenever you're using the ossn-make-sure
class. You don't need an extra language file entry for that.
Due to the many requests in the past for additonal features and components we have decided to develope a premium version. Features like Hashtags, Videos, Polls, Events, Stories, Link Preview, etc included in it.
$199 (Life Time)