Howto: CJBlog – Easyprofile integration
Howto: CJBlog - Easyprofile integration
Integrate Easyprofile avatar and user defined author info text into cjblog while keeping the cjblog author page (this is different from eg jomsocial integration > here you will be referred to the jomsocial user page thus losing the cjblog functionality)
You need to install the Jomsocial bridge provided by Easyprofile (for the avatar part)
you can see it in action here: www.lerendeleiders.nl/blogoverzicht
Changes against:
cjlib 2.1.4 (EDIT 20141209)
cjblog 1.2.2
changed files:
/administrator/language/en-GB/en-GB.com_cjblog.ini
/components/com_cjblog/api.php
/components/com_cjblog/models/users.php
/components/com_cjblog/views/profile/tmpl/default.php
/components/com_cjlib/framework/functions.php
/components/com_cjlib/framework/api.php
/administrator/component/com_cjblog/config.xml
/modules/mod_articlesuggestions/mod_articlesuggestions.xml
/plugins/content/articlesuggestions/articlesuggestions.xml
changes and additions:
> Labels for CJBLOG backend
./administrator/language/en-gb/en-GB.com_cjblog.ini
Add
> about text under article and on cjblog profile page
./components/com_cjblog/api.php
Replace $query part with:
> about text in bloggers list overview
./components/com_cjblog/models/users.php
Replace $query part with:
> make selection in back-end (integration tab)
./administrator/component/com_cjblog/config.xml
add
> Get easyprofile avatar and link to cjblog user profile
./component/com_cjlib/framework/api.php
add to: public function getUserAvatarImage
Add to: public function getUserProfileUrl
> Display easyprofile avatar and disable edit avatar and edit about text possibility (must be edited in Easyprofile)
./component/com_cjblog/views/profile/tmpl/default.php
Add to php part:
replace
with
Replace 2x!
with
> add Easyprofile choice possibility to Articlesuggestions
./modules/mod_articlesuggestions/mod_articlesuggestions.xml
AND
./plugins/content/articlesuggestions/articlesuggestions.xml
Add:
You need to install the Jomsocial bridge provided by Easyprofile (for the avatar part)
you can see it in action here: www.lerendeleiders.nl/blogoverzicht
Changes against:
cjlib 2.1.4 (EDIT 20141209)
cjblog 1.2.2
changed files:
/administrator/language/en-GB/en-GB.com_cjblog.ini
/components/com_cjblog/api.php
/components/com_cjblog/models/users.php
/components/com_cjblog/views/profile/tmpl/default.php
/components/com_cjlib/framework/functions.php
/components/com_cjlib/framework/api.php
/administrator/component/com_cjblog/config.xml
/modules/mod_articlesuggestions/mod_articlesuggestions.xml
/plugins/content/articlesuggestions/articlesuggestions.xml
changes and additions:
> Labels for CJBLOG backend
./administrator/language/en-gb/en-GB.com_cjblog.ini
Add
COM_CJBLOG_EASYPROFILE_ABOUT="Easyprofile About field"
COM_CJBLOG_EASYPROFILE_ABOUT_DESC="Type the Easyprofile fieldname that holds the text about the author"
> about text under article and on cjblog profile page
./components/com_cjblog/api.php
Replace $query part with:
$params = JComponentHelper::getParams(CJBLOG);
$user_avatar = $params->get('user_avatar', 'cjblog');
if ($user_avatar == "easyprofile") {
$about = "e." . $params->get('easyprofile_about', 'author_info');
}
if ($user_avatar == "easyprofile") {
$query = '
select
ju.id, u.avatar, ' . $about . ' AS about, u.points, u.num_articles, u.num_badges, u.country, u.profile_views,
ju.name, ju.username, ju.email, ju.block, ju.registerDate, ju.lastvisitDate, ju.params
from
#__users ju
left join
'.T_CJBLOG_USERS.' u on u.id = ju.id
left join
#__jsn_users AS e on ju.id = e.id
where
ju.id in ('.implode(',', $notfound).')';
} else {
$query = '
select
ju.id, u.avatar, u.about, u.points, u.num_articles, u.num_badges, u.country, u.profile_views,
ju.name, ju.username, ju.email, ju.block, ju.registerDate, ju.lastvisitDate, ju.params
from
#__users ju
left join
'.T_CJBLOG_USERS.' u on u.id = ju.id
where
ju.id in ('.implode(',', $notfound).')';
}
> about text in bloggers list overview
./components/com_cjblog/models/users.php
Replace $query part with:
$params = JComponentHelper::getParams(CJBLOG);
$user_avatar = $params->get('user_avatar', 'cjblog');
if ($user_avatar == "easyprofile") {
$about = "e." . $params->get('easyprofile_about', 'author_info');
}
if ($user_avatar == "easyprofile") {
$query = '
select
u.id, ' . $about . ' AS about, u.avatar, u.points, u.num_articles, u.num_badges,
ju.name, ju.username, ju.registerDate, ju.lastvisitDate
from
'.T_CJBLOG_USERS.' u
left join
#__users ju on ju.id = u.id
left join
#__jsn_users AS e on ju.id = e.id
where
'.$where.'
order by
'.$order.' '.$order_dir;
} else {
$query = '
select
u.id, u.about, u.avatar, u.points, u.num_articles, u.num_badges,
ju.name, ju.username, ju.registerDate, ju.lastvisitDate
from
'.T_CJBLOG_USERS.' u
left join
#__users ju on ju.id = u.id
where
'.$where.'
order by
'.$order.' '.$order_dir;
}
> make selection in back-end (integration tab)
./administrator/component/com_cjblog/config.xml
add
<field name="user_avatar" type="list" class="btn-group" default="none" label="COM_CJBLOG_USER_AVATAR" description="COM_CJBLOG_USER_AVATAR_DESC">
...
<option value="easyprofile">EasyProfile</option>
...
</field>
<field name="easyprofile_about" type="text" class="" default="author_info" label="COM_CJBLOG_EASYPROFILE_ABOUT" description="COM_CJBLOG_EASYPROFILE_ABOUT_DESC"/>
> Get easyprofile avatar and link to cjblog user profile
./component/com_cjlib/framework/api.php
add to: public function getUserAvatarImage
case 'easyprofile':
require_once JPATH_ROOT.'/components/com_community/defines.community.php';
require_once JPATH_ROOT.'/components/com_community/libraries/core.php';
require_once JPATH_ROOT.'/components/com_community/helpers/string.php';
$user = CFactory::getUser( $userId );
$avatar = $user->getAvatar();
if($urlOnly == false){
$imgAttribs['height'] = $height.'px';
$imgAttribs['class'] = 'avatar avatar img-circle';
$imgAttribs['style'] = 'max-height: '.$height.'px; display: block; margin: 0 auto';
$avatar = '<img src="'.$avatar.'" alt="'.$alt.'" '.trim((is_array($imgAttribs) ? JArrayHelper::toString($imgAttribs) : $imgAttribs).' /').'>';
}
break;
Add to: public function getUserProfileUrl
case 'easyprofile':
$api = JPATH_ROOT.'/components/com_cjblog/api.php';
if(file_exists($api))
{
require_once $api;
$url = CjBlogApi::get_user_profile_url($userId, 'name', true, $attribs);
}
break;
> Display easyprofile avatar and disable edit avatar and edit about text possibility (must be edited in Easyprofile)
./component/com_cjblog/views/profile/tmpl/default.php
Add to php part:
$params = JComponentHelper::getParams(CJBLOG);
$api = new CjLibApi();
if ($params->get('user_avatar', 'cjblog') == "easyprofile") {
$avatar = $api->getUserAvatar($params->get('user_avatar', 'cjblog'), $params->get('user_avatar', 'cjblog'), $this->profile['id'], $this->profile['name'], 200, null, array(), array());
} else {
$avatar = "<img class="avatar photo" src="".$this->profile['avatar']."" alt="".$this->profile['name']."" style="width: 100%">";
}
replace
<img class="avatar photo" src="<?php echo $this->profile['avatar'];?>" alt="<?php echo $this->profile['name']?>" style="width: 100%">
with
<?php echo $avatar;?>
Replace 2x!
<?php if(!$user->guest && ($user->id == $this->profile['id'] || $user->authorise('core.manage'))):?>
with
<?php if(!($params->get('user_avatar', 'cjblog') == "easyprofile") && !$user->guest && ($user->id == $this->profile['id'] || $user->authorise('core.manage'))):?>
> add Easyprofile choice possibility to Articlesuggestions
./modules/mod_articlesuggestions/mod_articlesuggestions.xml
AND
./plugins/content/articlesuggestions/articlesuggestions.xml
Add:
<option value="easyprofile">EasyProfile</option>
Access to viewing replies is restricted.
No replies found.
You do not have permissions for replying to this topic.