Notice

The forum is in read only mode.

Support Forum

Welcome! Support Forums have been reactivated

How to load custom style for specific user group?

6 years 6 months ago
Licenses:
JomSocial Active

Hello.
I created "VIP" joomla user group and would like to display some specific styles for it (another color for avatar border: red instead of white)



For example, as default, there is style:
.joms-avatar img, .joms-avatar--stream img, .joms-avatar--comment img, .joms-avatar--focus img, .joms-avatar--video img {
display: inline-block;
line-height: 0;
padding: 3px;
background: #fff;
}


I would like to display "background: #000;" if joomla user group = 10. How can I do it?
I read documentation.jomsocial.com/wiki/Add_the...he_Joomla_User_Group and documentation.jomsocial.com/wiki/Template_Developer_Kit

I set "demo" user to "VIP" group (ID = 10).
I uploaded file "general.header.php" to folder: /templates/my_joomla_template/html/com_community/layouts/

this file contain code:
<?php
// Lets obtain the user object first
$juser = CFactory::getUser(); // Get the user object you want to display the badge for. On profile page you can use $juser = CFactory::getRequestUser(); to obtain the user object of the user we are looking at.
$juserid = $juser->id; // extract the user ID

// Now, lets get the array of all Joomla User Groups user is member of
jimport( 'joomla.user.helper' );
$groups = JUserHelper::getUserGroups($juserid);
?>


And this:
<!-- Display the badge if user is member of the Joomla User Group with ID 8 -->
<?php if(in_array(10, $groups)): ?>
<style>
.joms-avatar img, .joms-avatar--stream img, .joms-avatar--comment img, .joms-avatar--focus img, .joms-avatar--video img{
background: #ff0000 !important;
}
</style>
<?php endif ?>


but this style (#ff0000) apply only if user (from group ID=10) is loged. It apply only for him.

Can you please help with it?

Thanks.


Sorry for my English
Attachments:
6 years 6 months ago
  • Dimas's Avatar
  • Dimas
  • Visitor
  • Thank you received: 0
Licenses:

Hi,

ON this code :

$juser = CFactory::getUser();
it will get the logged user id by default, so please change to this code
$juser = CFactory::getUser(USER_ID);
that code will apply any user depending the "USER_ID"

I hope it will help.

6 years 6 months ago
Licenses:
JomSocial Active

Hi. I changed code, but can't see the difference.
Wnen I visit site like guest, everything looks as usual.
New style still apply only when I logging as "demo" (joomla user group 10). And it apply for all users:



I supposed that:
1) this style will apply only for VIP-users's avatar border.
2) anybody can see this style (not only VIP-users) - like "NO LICENSE" badge at jomsocial.com.

Seems I was mistaken. So, how does it work?
How to apply some extra color / background for VIP-users?

Thanks.


Sorry for my English
Attachments:
6 years 6 months ago
  • Dimas's Avatar
  • Dimas
  • Visitor
  • Thank you received: 0
Licenses:

Hi,

Where do you want to apply it? for all page? its hard to be implmented.. its really tricky because you need modify many files, for the pointer code you can use this

$user  = JFactory::getUser(USER_ID);
$user_groups = $user->groups;
// check if this user have VIP id
print_r($user_groups);

6 years 6 months ago
Licenses:
JomSocial Active

Hi.
I supposed that it's possible to do something like that.
For example, simple user's activity looks loke this:



But if user in specific group (or may be JS-Featured user) I would like to display not budge but some custom styles:

ts really tricky because you need modify many files

Seems I really need to edit this stream activity temlate layout (make override) and "display some extra class if user is VIP"?

Anyway, I don't know how to use your new code:

$user = JFactory::getUser(USER_ID);
$user_groups = $user->groups;
// check if this user have VIP id
print_r($user_groups);


In this code? :(

<?php
// Lets obtain the user object first
$juser = CFactory::getUser(USER_ID); // Get the user object you want to display the badge for. On profile page you can use $juser = CFactory::getRequestUser(); to obtain the user object of the user we are looking at.
$juserid = $juser->id; // extract the user ID
// Now, lets get the array of all Joomla User Groups user is member of
jimport( 'joomla.user.helper' );
$groups = JUserHelper::getUserGroups($juserid);
?>


I planned to use "VIP" and "PRO" user statuses. But seems the best way is to use "Multiple Profiles" feature to make this profile typoes looks different?

I wish "Featured users" (default JS option) could get some extra class by JS as default everywhere.

Can you please tell what files was edited to display "JS ACTIVE" badge at jomsocial.com? :)

Thanks.


Sorry for my English
Attachments:
6 years 6 months ago
  • Dimas's Avatar
  • Dimas
  • Visitor
  • Thank you received: 0
Licenses:

Hi,

That is smart solution, user jomsocial profile type and use watermark avatar for difference the general user with VIP user.

Create profile type, on Jomsocial backend->Profile->Multiple Profiles->create new profile type, and on the form upload "Watermark" config item.

thank you!

6 years 6 months ago
Licenses:
JomSocial Active

Hi. Can you please tell what file(s) was edited to display "JS ACTIVE" badge at jomsocial.com and may be publish code from it (because code from documentation apply for me only after login)?

I would like to display some badge like there.

Thanks.


Sorry for my English
6 years 6 months ago
  • Dimas's Avatar
  • Dimas
  • Visitor
  • Thank you received: 0
Licenses:

JS active? please explain more..

6 years 6 months ago
Licenses:
JomSocial Active

Hi. I mean this badge that was mentioned in documentation.


Thanks.


Sorry for my English
Attachments:
6 years 6 months ago
  • Dimas's Avatar
  • Dimas
  • Visitor
  • Thank you received: 0
Licenses:

we use custom code, I dont recommended you to use custom / hack method, your issue actually can be fixed easily, just activate multiprofile and create watermark avatar there

6 years 6 months ago
Licenses:
JomSocial Active

Hi. Is it possible to use "if Featured user" condition?

Should I add this code to general.header.php:

$featured = new CFeatured(FEATURED_USERS);
$featuredList = $featured->getItemIds();

- or I need to use another code in this file?

And this one to place where need to display badge?

<?php if (is_array($featuredList) && in_array($row->user->id, $featuredList)) { ?>
custom badge or class-style
<?php } ?>

or may be this one:

<?php echo ($profile->featured == true) ? 'CUSTOM-CODE-THERE' : ' '; ?>


but it didn't helped.
Thanks.


Sorry for my English
6 years 6 months ago
  • Dimas's Avatar
  • Dimas
  • Visitor
  • Thank you received: 0
Licenses:

Hi,

I am sorry your request is too many hack tehnical issue, and that is not simple hack, I suggest you hire 3rd party developer.

thank you!

6 years 4 months ago
Licenses:
JomSocial Active

Hi. I hope it will be possible in future as default feature display "badge" for featured users, like easysocial do (new username everywhere). Thanks.


Sorry for my English
Attachments:
Moderators: Piotr Garasiński
Powered by Kunena Forum

Join 180,000 websites creating Amazing communities

JomSocial is the most complete, easy-to-use addon that turns Joomla CMS into a
full -fledged, social networking site

TRY NOW BUY NOW