PDA

Zobacz pełną wersję : Plugin User Extended Fields



klik
28-08-2011, 16:01
Chciałem usunąć z tego pluginu pozycje takie jak "zip code" i "address" ale nie ma ich w pliku userextendedfields.php. Parametry zaczynają się od "city"


<?php
// no direct access
defined('_JEXEC') or die('Restricted access');

// Load the K2 plugin API
JLoader::register('K2Plugin', JPATH_ADMINISTRATOR.DS.'components'.DS.'com_k2'.DS .'lib'.DS.'k2plugin.php');

class plgK2Userextendedfields extends K2Plugin {

// Required global reference parameters
var $pluginName = 'userExtendedFields';
var $pluginNameHumanReadable = 'User Extended Fields for K2';
var $plgCopyrightsStart = "\n\n<!-- JoomlaWorks \"User Extended Fields for K2\" Plugin (v1.0) starts here -->\n";
var $plgCopyrightsEnd = "\n<!-- JoomlaWorks \"User Extended Fields for K2\" Plugin (v1.0) ends here -->\n\n";

function plgK2Userextendedfields(&$subject, $params) {
parent::__construct($subject, $params);
}

function onK2UserDisplay(&$user, &$params, $limitstart){

// API
$mainframe= &JFactory::getApplication();
$document = &JFactory::getDocument();

// Assign paths
$sitePath = JPATH_SITE;
$siteUrl = substr(JURI::root(), 0, -1);

// Check if plugin is enabled
if(JPluginHelper::isEnabled('k2',$this->pluginName)==false) return;

// Load the plugin language file the proper way
if($mainframe->isAdmin()){
JPlugin::loadLanguage( 'plg_k2_'.$this->pluginName );
} else {
JPlugin::loadLanguage( 'plg_k2_'.$this->pluginName, 'administrator' );
}

// ----------------------------------- Get plugin parameters -----------------------------------

// Global plugin params
$plugin =& JPluginHelper::getPlugin('k2',$this->pluginName);
$pluginGlobalParams = new JParameter($plugin->params);
$contactDetails = $pluginGlobalParams->get('contactDetails',0);
$socialProfiles = $pluginGlobalParams->get('socialProfiles',1);

// K2 User plugin specific params
$pluginParams = new K2Parameter($user->plugins,'',$this->pluginName);
if($contactDetails){
$city = $pluginParams->get('city');
$stateOrProvince = $pluginParams->get('stateOrProvince');
$country = $pluginParams->get('country');
$telephone = $pluginParams->get('telephone');
$mobile = $pluginParams->get('mobile');
}
if($socialProfiles){
$facebook = $pluginParams->get('facebook');
$twitter = $pluginParams->get('twitter');
$google = $pluginParams->get('google');
$linkedin = $pluginParams->get('linkedin');
$youtube = $pluginParams->get('youtube');
$vimeo = $pluginParams->get('vimeo');
$blip = $pluginParams->get('blip');
$flickr = $pluginParams->get('flickr');
$picasa = $pluginParams->get('picasa');
}

// ----------------------------------- Requirements -----------------------------------
require_once(dirname(__FILE__).DS.$this->pluginName.DS.'includes'.DS.'helper.php');

// ----------------------------------- Head tag includes -----------------------------------
$pluginCSS = userExtendedFieldsHelper::getTemplatePath($this->pluginName,'css/template.css');
$pluginCSS = $pluginCSS->http;
$pluginCSS = '
'.JHTML::_('behavior.mootools').'
<style type="text/css" media="all">
@import "'.$pluginCSS.'";
</style>
';

// Append head includes, but not when we're outputing raw content in K2
if(JRequest::getCmd('format')!='raw'){
userExtendedFieldsHelper::loadHeadIncludes($this->plgCopyrightsStart.$pluginCSS.$this->plgCopyrightsEnd);
}

// ----------------------------------- Fetch the template -----------------------------------
ob_start();
$getTemplatePath = userExtendedFieldsHelper::getTemplatePath($this->pluginName,'default.php');
$getTemplatePath = $getTemplatePath->file;
include($getTemplatePath);
$getTemplate = $this->plgCopyrightsStart.ob_get_contents().$this->plgCopyrightsEnd;
ob_end_clean();

// ----------------------------------- Output -----------------------------------
return $getTemplate;

}

} // End class
Natomiast te pozycje są w pliku default.php. Jednak gdy usunę pozycje których nie chce to potem na stronie wywala mi błędy po kliknięciu na użytkownika.

<?php
// no direct access
defined('_JEXEC') or die('Restricted access');

// Load the K2 plugin API
JLoader::register('K2Plugin', JPATH_ADMINISTRATOR.DS.'components'.DS.'com_k2'.DS .'lib'.DS.'k2plugin.php');

class plgK2Userextendedfields extends K2Plugin {

// Required global reference parameters
var $pluginName = 'userExtendedFields';
var $pluginNameHumanReadable = 'User Extended Fields for K2';
var $plgCopyrightsStart = "\n\n<!-- JoomlaWorks \"User Extended Fields for K2\" Plugin (v1.0) starts here -->\n";
var $plgCopyrightsEnd = "\n<!-- JoomlaWorks \"User Extended Fields for K2\" Plugin (v1.0) ends here -->\n\n";

function plgK2Userextendedfields(&$subject, $params) {
parent::__construct($subject, $params);
}

function onK2UserDisplay(&$user, &$params, $limitstart){

// API
$mainframe= &JFactory::getApplication();
$document = &JFactory::getDocument();

// Assign paths
$sitePath = JPATH_SITE;
$siteUrl = substr(JURI::root(), 0, -1);

// Check if plugin is enabled
if(JPluginHelper::isEnabled('k2',$this->pluginName)==false) return;

// Load the plugin language file the proper way
if($mainframe->isAdmin()){
JPlugin::loadLanguage( 'plg_k2_'.$this->pluginName );
} else {
JPlugin::loadLanguage( 'plg_k2_'.$this->pluginName, 'administrator' );
}

// ----------------------------------- Get plugin parameters -----------------------------------

// Global plugin params
$plugin =& JPluginHelper::getPlugin('k2',$this->pluginName);
$pluginGlobalParams = new JParameter($plugin->params);
$contactDetails = $pluginGlobalParams->get('contactDetails',0);
$socialProfiles = $pluginGlobalParams->get('socialProfiles',1);

// K2 User plugin specific params
$pluginParams = new K2Parameter($user->plugins,'',$this->pluginName);
if($contactDetails){
$city = $pluginParams->get('city');
$stateOrProvince = $pluginParams->get('stateOrProvince');
$country = $pluginParams->get('country');
$telephone = $pluginParams->get('telephone');
$mobile = $pluginParams->get('mobile');
}
if($socialProfiles){
$facebook = $pluginParams->get('facebook');
$twitter = $pluginParams->get('twitter');
$google = $pluginParams->get('google');
$linkedin = $pluginParams->get('linkedin');
$youtube = $pluginParams->get('youtube');
$vimeo = $pluginParams->get('vimeo');
$blip = $pluginParams->get('blip');
$flickr = $pluginParams->get('flickr');
$picasa = $pluginParams->get('picasa');
}

// ----------------------------------- Requirements -----------------------------------
require_once(dirname(__FILE__).DS.$this->pluginName.DS.'includes'.DS.'helper.php');

// ----------------------------------- Head tag includes -----------------------------------
$pluginCSS = userExtendedFieldsHelper::getTemplatePath($this->pluginName,'css/template.css');
$pluginCSS = $pluginCSS->http;
$pluginCSS = '
'.JHTML::_('behavior.mootools').'
<style type="text/css" media="all">
@import "'.$pluginCSS.'";
</style>
';

// Append head includes, but not when we're outputing raw content in K2
if(JRequest::getCmd('format')!='raw'){
userExtendedFieldsHelper::loadHeadIncludes($this->plgCopyrightsStart.$pluginCSS.$this->plgCopyrightsEnd);
}

// ----------------------------------- Fetch the template -----------------------------------
ob_start();
$getTemplatePath = userExtendedFieldsHelper::getTemplatePath($this->pluginName,'default.php');
$getTemplatePath = $getTemplatePath->file;
include($getTemplatePath);
$getTemplate = $this->plgCopyrightsStart.ob_get_contents().$this->plgCopyrightsEnd;
ob_end_clean();

// ----------------------------------- Output -----------------------------------
return $getTemplate;

}

} // End class
Czy ktoś może mi powiedzieć w jakim pliku mogę usunąć te pozycje?
Nie jest mi to do szczęścia niezbędnie potrzebne, bo jak ktoś tego nie wypełni to i tak nie widać tego w podglądzie profilu użytkownika. Ale wolałbym, aby tego nie było.

Od razu powiem że nie znam się na PHP więc jeśli to wyższa szkoła jazdy to po prostu napiszcie mi abym sobie dał spokój i zostawię tak jak jest.

Dziękuje.

a_m
28-08-2011, 16:10
default.php z plugins/k2/userExtendedFields/tmpl + te same parametry z userExtendedFields.xml

klik
28-08-2011, 16:19
Pomogło. :)

Dziękuje bardzo.