Vanilla 1.1.4 is a product of Lussumo. More Information: Documentation, Community Support.
Help keep Vanilla free:<table><tr>
<script type="text/javascript"
src="http://www.flickr.com/badge_code_v2.gne?count=10&display=latest&size=s&layout=h&source=user&user=[user_id]">
</script>
</tr></table>But anyhow, I'd recommend looking at Mark's Flickrizer extension for a good, simple example of the user account field and member info page html. It might be easiest to simply have an easily edited value inside the extension for the adminstration options, though. Creating a whole UI and storing mechanism for two integers seems a little impractical.
<?php
/*
Extension Name: Flickrizer
Extension Url: http://lussumo.com/addons/
Description: Allows users to add their flickr photostream to their account
Version: 0.1
Author: Mark O'Sullivan
Author Url: http://www.markosullivan.ca/
*/
// Define the required Customizations for this extension
$Context->Configuration['CUSTOMIZATION_FLICKR_URL'] = '';
$Context->SetDefinition('CUSTOMIZATION_FLICKR_URL', 'Flickr RSS Url');
$Context->SetDefinition('CUSTOMIZATION_FLICKR_URL_DESCRIPTION', 'You can add your recent Flickr photostream to your account by providing the url to your flickr rss feed.');
$Context->SetDefinition('FlickrPhotostream', 'Flickr Photostream');
// Attach to the user account being viewed if there is no postback action
if ($Context->SelfUrl == 'account.php' && ForceIncomingString('PostBackAction', '') == '') {
// Retrieve the photostream before the page is rendered so errors can be trapped properly
function Account_RetrieveFlickrPhotostream(&$Account) {
// If there is a flickr stream defined, retrieve the feed
$FlickrRSSUrl = $Account->User->Customization('CUSTOMIZATION_FLICKR_URL');
if ($FlickrRSSUrl != '') {
$FlickrRSS = OpenURL($FlickrRSSUrl, $Account->Context);
if ($FlickrRSS) {
$Images = array();
$Titles = array();
$Links = array();
$Lines = explode("\n", $FlickrRSS);
$Length = count($Lines);
$FoundLinks = 0;
for ($i = 0; $i < $Length; $i++) {
if (strpos($Lines[$i], '<media:thumbnail url="') !== false) {
$Image = trim(str_replace('<media:thumbnail url="', '', $Lines[$i]));
$Images[] = substr($Image, 0, strpos($Image, '"'));
} elseif (strpos($Lines[$i], '<media:title>') !== false) {
$Title = trim(str_replace(array('<media:title>','</media:title>'), array('', ''), $Lines[$i]));
$Titles[] = $Title;
} elseif (strpos($Lines[$i], '<link>') !== false) {
$FoundLinks++;
if ($FoundLinks > 2) {
$Link = trim(str_replace(array('<link>', '</link>'), array('',''), $Lines[$i]));
$Links[] = $Link;
}
}
}
$ImageCount = count($Images);
$TitleCount = count($Titles);
$LinkCount = count($Links);
if ($ImageCount == $TitleCount && $TitleCount == $LinkCount && $ImageCount > 0) {
$Photostream = '<h2>'.$Account->Context->GetDefinition('FlickrPhotostream').'</h2>
<div id="FlickrStream" class="clearfix">';
for ($i = 0; $i < $ImageCount; $i++) {
$Photostream .= '<a href="'.$Links[$i].'" style="background-image: url('.$Images[$i].');" title="'.$Titles[$i].'"> </a>';
}
$Photostream .= '</div>';
$Account->DelegateParameters['FlickrPhotostream'] = $Photostream;
}
}
}
}
// Render the photos, which have been stored in the FlickrPhotos Delegate Parameter
function Account_RenderFlickrPhotostream(&$Account) {
if (array_key_exists('FlickrPhotostream', $Account->DelegateParameters)) {
echo $Account->DelegateParameters['FlickrPhotostream'];
}
}
$Context->AddToDelegate('Account',
'Constructor',
'Account_RetrieveFlickrPhotostream');
$Context->AddToDelegate('Account',
'PostProfileRender',
'Account_RenderFlickrPhotostream');
$Head->AddStylesheet('extensions/Flickrizer/style.css');
}
?><?php
/*
Extension Name: Flickrizer 2
Extension Url: http://lussumo.com/addons/
Description: Allows users to add their flickr photostream to their account
Version: 0.1
Author: You
Author Url: n/a
*/
// Define the required Customizations for this extension
$Context->Configuration['CUSTOMIZATION_FLICKR_USERNAME'] = '';
// Note: By defining a Configuration variable that begins with "CUSTOMIZATION_", you are adding a
// customization to the user accounts page. This means that an input will now appear on that
// "Personal Information" form under "Other Settings"
// Now we make a couple of dictionary entries for the labels that will appear around the customization
// input:
$Context->SetDefinition('CUSTOMIZATION_FLICKR_USERNAME', 'Flickr Username');
$Context->SetDefinition('CUSTOMIZATION_FLICKR_USERNAME_DESCRIPTION', 'You can add your recent Flickr photostream to your account by providing your flickr username.');
// Attach to the user account being viewed if there is no postback action
if ($Context->SelfUrl == 'account.php' && ForceIncomingString('PostBackAction', '') == '') {
// I'm assuming your javascript will render it's thumbs to the screen by identifying an element and
// then adding contents to the page after it using some wacky DOM navigation. I also made your js
// file a php file because you're going to need to render the javascript dynamically so you can get
// the user's name.
$Head->AddScript('extensions/Flickrizer2/functions.php?user_id='.ForceIncomingInt("u", $Context->Session->UserID));
}
?><?php
// Description: File used by Flickrizer 2 extension to get some dynamic information to be rendered by javascript.
include('../../appg/settings.php');
include('../../conf/settings.php');
include('../../appg/init_ajax.php');
$UserID = ForceIncomingInt('user_id', 0);
// Don't bother doing anything if the user isn't valid
if ($UserID > 0) {
// Retrieve a full user object for the requested user_id:
$um = $Context->ObjectFactory->NewContextObject($Context, 'UserManager');
$User = $um->GetUserById($UserID);
// Get the user's CUSTOMIZATION_FLICKR_USERNAME setting:
$FlickrUsername = $User->Customization('CUSTOMIZATION_FLICKR_USERNAME');
// Only render the stuff if the flickr username was entered by the user
if (ForceString($FlickrUsername, '') != '') {
// Set a definition for the heading above the flickr thumbnails - this would then have
// to be used in your javascript somewhere.
$Context->SetDefinition('FlickrPhotostream', 'Flickr Photostream');
// Render your javascript, using the $FlickrUsername where necessary
// ...
}
}
// Finally, clean up the context object
$Context->Unload();
?>1 to 5 of 5