The Promote plugins help the user to easily promote thier content on your site. The available plugins are for JomSocial profile, events, groups, Community Builder profile and Sobi list. You can build your own promote plugin for any extension that you need. Follow the below documentation for it.
These plugins are of type socialadspromote.
Plugin File Structure
- yourpromotename.xml(file)
- yourpromotename.php(file)
We are looking at the "Plugin for Promoting JS Events" plugin in this documentation.
yourpromotename.xml
Social Ads - Promote List JomSocial Events
TechJoomla
Mar 2012
Techjoomla. All Rights Reserved.
extensionstechjoomla.com
http://www.techjoomla.com
http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
2.7.3
Plugin for Promoting JS Events
plug_promote_jsevents.php
en-GB/en-GB.plg_socialadspromote_plug_promote_jsevents.ini
yourpromotename.php
load('plg_socialadspromote_promote_jsevents', JPATH_ADMINISTRATOR);
class plgsocialadspromoteplug_promote_jsevents extends JPlugin
{
/*
*Returns an array of value & text for options for the select box
*
*@return array of object having value and text
* value will be the plugin name without the extension like plug_promote_jsgroups pipe(ie.|) seperated with the promote item id
* text the title of the promote item
*/
//function promotlist starts
function onPromoteList()
{
jimport( 'joomla.filesystem.file' );
$db = JFactory::getDBO();
$user = JFactory::getUser();
/*$name will have the plugin name without the extension like plug_promote_jsgroups*/
$name = JFile::getName(__FILE__);
$name = JFile::stripExt($name);
/*check if JomSocial insalled*/
$jschk = socialadshelper::jschk();
if(!empty($jschk)){
$query = "SELECT CONCAT_WS('|', '".$name."', e.id) as value, e.title AS text FROM #__community_events AS e
LEFT JOIN #__users AS u ON e.creator = u.id
WHERE u.id =".$user->id;
$db->setQuery($query);
$itemlist = $db->loadObjectlist();
/*
*The return variable $itemlist should be of the following format
*array(
*[0] = object('value'=>'pluginame|id1',
* 'text'=>'text1'
* ),
*[1] = object('value'=>'pluginame|id2',
* 'text'=>'text2'
* )
*)
*/
if(empty($itemlist))
{
$list = array();
$list[0]->value=$name.'|'.'0';
$list[0]->text=JText::_("NO_EVENTS");
return $list;
}
else{
return $itemlist;
}
}
else
{
$list = array();
$list[0]->value=$name.'|'.'0';
$list[0]->text=JText::_("INSTALLJS");
return $list;
}
}//function promotlist ends
/*
*Returns Ad data to auto populate the Ad fields of create ad view
*
*@param int id of the selected option in the selectbox
*@return object containing values (ie url,title,image,bodytext) for populate ad fields
*/
//function promot data starts
function onPromoteData($id)
{
$db = JFactory::getDBO();
$id = JRequest::getInt('id');
$Itemid = JRequest::getInt('Itemid');
$jschk = socialadshelper::jschk();
if(!empty($jschk)){
$query = "SELECT title AS title, avatar AS image, description AS bodytext
FROM #__community_events
WHERE id=".$id;
$db->setQuery($query);
$previewdata = $db->loadObjectlist();
$previewdata[0]->url = JURI::root().substr(JRoute::_('index.php?option=com_community&view=events&task=viewevent&eventid='.$id.'&Itemid='.$Itemid),strlen(JURI::base(true))+1);
if($previewdata[0]->image == ''){
$previewdata[0]->image = 'components/com_community/assets/event.png';
}
$previewdata[0]->bodytext = strip_tags($previewdata[0]->bodytext);
return $previewdata;
}
else
{
return '';
}
}
}//class ends