custom tab

8 years 10 months ago - 8 years 10 months ago #265313 by naboman
Replied by naboman on topic custom tab
I'm using this:

<?php
Global $_CB_framework;
jimport( 'joomla.user.helper' );
$myId = $_CB_framework->myId();
$userId = CBuser::getMyUserDataInstance($myId);
$user = JFactory::getUser();
$userId = $user->id;
$userProfile = JUserHelper::getProfile( $userId );
echo "User ID: " . $userId;
?>

If you visit:
www.montear.com/pruebas/febrero/component/comprofiler/userprofile/rehalito

or here:
www.montear.com/pruebas/febrero/component/comprofiler/userprofile/Arnau

and press over "prueba" tab, you can see in both:
User ID: 0

If you are logged, you always see the same number (logged user id)

Please Log in to join the conversation.

8 years 10 months ago - 8 years 10 months ago #265323 by krileon
Replied by krileon on topic custom tab
That's not how a custom plugin tab is constructed. Please see the example code and example plugin I've provided. I've no idea how that's even being output into the tab unless you're using a Custom HTML field with something like Sourcerer. Please see the below example in this case to grab the viewing user and displayed user objects.

global $_CB_framework;

$displayedUser = CBuser::getUserDataInstance( $_CB_framework->displayedUser() );
$viewingUser = CBuser::getMyUserDataInstance();

echo 'Displayed User ID: ' . $displayedUser->get( 'id' );
echo '<br />Viewing User ID: ' . $viewingUser->get( 'id' );

You don't need any of the Joomla API in your code to grab this information.


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.
The following user(s) said Thank You: naboman

Please Log in to join the conversation.

8 years 10 months ago #265327 by naboman
Replied by naboman on topic custom tab
i'm using Sourcerer (and all code is inside a delimiter field)

Please Log in to join the conversation.

8 years 10 months ago #265328 by naboman
Replied by naboman on topic custom tab
have you any cb 1.9 version of this plugin?

thx

Please Log in to join the conversation.

8 years 10 months ago #265329 by naboman
Replied by naboman on topic custom tab
perfect!! it seems this works...

But only "Displayed User ID"

Displayed User ID: 695
Viewing User ID:


THANK YOU VERY MUCH!!

Please Log in to join the conversation.

8 years 10 months ago #265330 by naboman
Replied by naboman on topic custom tab
I prefer your plugin (CB 1.9 version) instead to use sorcerer, because I need that if a tab is empty, it was hidden, and with sorcerer it doesn't work this way

here you can see it:

this tab has elements:
www.montear.com/pruebas/febrero/component/comprofiler/userprofile/lomby

this tab has no elements:
www.montear.com/pruebas/febrero/component/comprofiler/userprofile/arnau

thx

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.235 seconds

Facebook Twitter LinkedIn