custom tab

8 years 10 months ago #264971 by naboman
custom tab was created by naboman
Hi

I'm using php coding inside a CB custom tab to show user info (for example User X)... and it works, but if user X is login and he tries to see Y user profile, the php coding inside CB custom tab that is displaying is all about X user...


require_once($_SERVER.'/components/com_monteros/classes/CUsuario.php');
require_once($_SERVER.'/components/com_monteros/classes/CListaMonterias.php');

some of the code:

$usuario = new CUsuario();
$usuario->getActual();
$id_usuario = $usuario->id;
$esUsuarioRegistrado = $usuario->existe();


$listaMonterias = new CListaMonterias();
$listaMonterias->getFiltroPorOrganizador($usuario->id);
echo "<div class='lista_monterias_asociadas'>";

Please Log in to join the conversation.

8 years 10 months ago #265033 by krileon
Replied by krileon on topic custom tab
No idea, I can't advise you on custom coding. As you've just supplied inline code with no context I've no idea if you're using the proper tab classes or field classes depending on your usage. Your code doesn't seam to be using any of CBs API. The displayed user object is a variable of the tab class tab display function. Take a look at the CB Last Views Tab plugin as it's a pretty simple plugin that's utilizing our tab API.


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 to join the conversation.

8 years 10 months ago - 8 years 10 months ago #265289 by naboman
Replied by naboman on topic custom tab
thx, but
This is I need:

if I want to get current loged user, I must use:
$user =& JFactory::getUser();
$userId = $user->get( 'id' );

But What should I do if I need to know the ID of any another user, inside his profile?

I know [user_id] it works but I need use it inside php code... something like this:
$usuario = [user_id]; - but this, logically, doesn't work ;)

Please Log in to join the conversation.

8 years 10 months ago #265304 by krileon
Replied by krileon on topic custom tab
You need to be using our tab class usage for a tab to properly display. The display function contains the viewing user object. I'm not going to advise you on how to string together random APIs to force what you're wanting; that's not the right way to do this and it probably will just repeatedly break or not work at all.

$viewer = CBuser::getMyUserDataInstance();

Take a look at last views tab and its getLastViewsTab class followed by its getDisplayTab function. That plus the XML node "tabs" in its XML file is all that's needed for a custom plugin tab to function. I would say it's the perfect example plugin as it contains template usage, backend xml usage, tab display usage, and demonstrates multiple APIs.

So for example you'd have the below structure.

XML:
	<tabs>
		<tab name="Example" description="" class="getExampleTab" fields="0" position="canvas_main_middle" displaytype="menunested" ordering_register="1" />
	</tabs>
PHP:
class getExampleTab extends cbTabHandler
{
	/**
	 * @param TabTable  $tab
	 * @param UserTable $user
	 * @param int       $ui
	 * @return null|string
	 */
	public function getDisplayTab( $tab, $user, $ui )
	{
		// Your code for displaying the tab here
	}
}


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 to join the conversation.

8 years 10 months ago #265305 by krileon
Replied by krileon on topic custom tab
To make things a little easier I put together the following example plugin. It installs, creates a tab, and contains the PHP class and functions for custom tab usage. I included the tab functions for handling display, edit, and registration output of a tab for all kinds of custom usage, but you only need to keep the functions you intend to use.


File Attachment:

File Name: example.zip
File Size:2 KB


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

Please Log in to join the conversation.

8 years 10 months ago #265311 by naboman
Replied by naboman on topic custom tab
thank you very much!!!

but I need CB 1.9 version

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.208 seconds

Facebook Twitter LinkedIn