Last active
August 29, 2015 13:57
-
-
Save mckelvey/9921851 to your computer and use it in GitHub Desktop.
This simple module and xphp snippet produce a link to edit the profile being viewed on any profiles details page regardless of login status.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
<xphp content="true"> | |
<if var="profiles_edit_link"/> | |
<content> | |
<div class="profiles_edit_link"> | |
<xphp var="profiles_edit_link" inner="true"/> | |
</div> | |
</content> | |
</xphp> | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$_LW->REGISTERED_APPS['profiles_edit_link']=array( | |
'title'=>'Profiles Edit Link', | |
'handlers'=>array('onWidgetFormat') | |
); | |
class LiveWhaleApplicationProfilesEditLink { | |
public function onWidgetFormat($type, $handler, $variables) { // alters widget variables before widgets are produced | |
global $_LW; | |
if ($type === 'profiles' && $handler === 'details') { | |
if (empty($GLOBALS['profiles_edit_link'])) { | |
$GLOBALS['profiles_edit_link'] = '<a href="/livewhale/?profiles_edit&id='.((int)$variables['id']).'" title="Edit '.$_LW->setFormatClean($variables['firstname']).'\'s Profile">Edit This Profile</a>'; | |
} | |
} | |
return $variables; // and return the variables | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment