Skip to Content Skip to Menu

🎃 Happy Halloween! Treat yourself with an awesome discount on memberships! Get 20% off now with code SPOOKY-2024!

Hide joomla module conditional to a field value

  • diogotu
  • diogotu
  • OFFLINE
  • Posts: 138
  • Thanks: 4
  • Karma: 0
11 years 4 months ago #228657 by diogotu
Hi, I would like to know if is possible to hide a joomla module "k2 user", depending on a field value!

I have created a field like this:

would you like to have a k2 profile? [] yes [] no

The feature that i was thinking about is, if yes show the "k2 user" module, if no, hide it!

Is that possible? Any plugin that you recommend?

Thanks

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48464
  • Thanks: 8280
  • Karma: 1443
11 years 4 months ago #228702 by krileon
There's no conditional show/hide of modules based off field values feature. Best you could do is try embedding the module inside of a CB Content module using Modules Anywhere or similar extensions then surrounding the embed with a IF substitution.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • diogotu
  • diogotu
  • OFFLINE
  • Posts: 138
  • Thanks: 4
  • Karma: 0
11 years 4 months ago #228722 by diogotu
Nice,

I never used the CB Content module! Looks very cool.

But i din't understand well how it works... I have read the documantation...

It works only if the member is logged in?

For example, i was trying to do this to links:

User CB Profile
User K2 Profile


using this code:
Code:
<a href="index.php?option=com_k2&amp;view=itemlist&amp;task=user&amp;id=[user_id]">User K2 Profile </a> <a href="index.php?option=com_comprofiler&task=userProfile&user=[user_id]">User CB Profile </a>

If the user is logged in, this links work, if the user is not logged in, the links doesn't work!

Is possible to have this links working for the site visitors, not logged in, being able visit others k2 and CB profiles?

I don't know if i was able to explain?
thanks
Diogo

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48464
  • Thanks: 8280
  • Karma: 1443
11 years 4 months ago #228723 by krileon
You're using a user id substitution in the links. So yes those URLs will only work if the user is logged in otherwise the user_id is going to be 0. It's just an HTML supported textarea that passes whatever you supply through CB substitutions. So normal substitution limitations and usages apply. Please see the below tutorial regarding substitution usage information.

www.joomlapolis.com/support/tutorials/107-use-cases/18353-using-substitutions-throughout-cb

Is possible to have this links working for the site visitors, not logged in, being able visit others k2 and CB profiles?

If they're viewing someones CB profile, yes. You can set user="#displayed" on your substitutions and it'll use the displayed profile for substitution usages. Otherwise you'll need to supply a static user id.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • diogotu
  • diogotu
  • OFFLINE
  • Posts: 138
  • Thanks: 4
  • Karma: 0
11 years 4 months ago - 11 years 4 months ago #228732 by diogotu

Is possible to have this links working for the site visitors, not logged in, being able visit others k2 and CB profiles?

If they're viewing someones CB profile, yes. You can set user="#displayed" on your substitutions and it'll use the displayed profile for substitution usages. Otherwise you'll need to supply a static user id.


Nice article, is not so easy to me understand, but i'm trying!

Would be something like that?
Code:
[cb:if user="#displayed"]<a href="index.php?option=com_k2&amp;view=itemlist&amp;task=user&amp;id=[user_id]">User K2 Profile </a>[/cb:if] [cb:if user="#displayed"]<a href="index.php?option=com_comprofiler&task=userProfile&user=[user_id]">User CB Profile </a>[/cb:if]

to get [user_id] of the page that is being visited?

Sorry for my difficult of understanding
Last edit: 11 years 4 months ago by diogotu.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48464
  • Thanks: 8280
  • Karma: 1443
11 years 4 months ago #228736 by krileon
If you want to make sure the viewing user is the user being displayed you'll want to use the below IF substitution to surround your substitution.

[cb:if user="#displayed" user_id="myid"]
This is me being displayed!
[/cb:if]

Another option is to just make sure the viewing user isn't a guest so [user_id] will always return the viewing users user_id.

[cb:if user="#me" user_id>"0"]
This is me being displayed!
[/cb:if]

Aside from the above you'll simply need to review the tutorial carefully as it covers multiple usages, parameter descriptions, and examples.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum