Preferred way to have public tab switchable?

18 years 4 weeks ago #10645 by ben_emo
A question probably for the dev's here: What's the preferred way to make a tab which displays on the users public profile switchable between visible and hidden?

Two ideas spring to mind:

1. Create two tabs in the plugin parameters - one used for registration / editing which should remain published, the second one for public display which can be published/unpublished as required.

2. Create an option in the single tab which allows you to turn the public display on or off.

I haven't actually tried to implement either of these methods yet so I may be missing something simple about the way this process is handled by CB, but thought I'd ask first and see if there's any useful advice!

Cheers..

Please Log in to join the conversation.

18 years 4 weeks ago #10649 by mikko
I would go for option 2. You need to write a plugin that creates a tab and a field in the tab when installed. When the tab is drawn, the plugin checks wether the field is checked and if not, it returns empty string.

See plugin api document. ListTab plugin is a good example for extending default tab behavior.

If you manage to do this, please post the code here.

mikko

Please Log in to join the conversation.

18 years 4 weeks ago #10654 by ben_emo
Ok this worked for me - I added an option in the tabs->tab->params section of the xml file like this:

[code:1]<param name="hidePublic"
label="Hide this tab on the public profile?"
type="list"
default="0"
description="Hide this tab on the public 'view profile' page?"
>
<option value="0">No</option>
<option value="1">Yes</option>
</param>[/code:1]

Then in the php file in getDisplayTab I do this check:

[code:1]function getDisplayTab($tab,$user,$ui) {
$hidePublic=$this->params->get('hidePublic');
if ( !$hidePublic ) {
// code here
}
}[/code:1]

And it only shows if the value is set to 1 in the parameters..

Please Log in to join the conversation.

18 years 3 weeks ago #10745 by BusinessbyDesign
Replied by BusinessbyDesign on topic Re:Preferred way to have public tab switchable?
I had trouble implementing this ...

I put the xml code in cb.menu.xml in the <tabs> section ... but when I tried to add the code for the getDisplayTab section of cb.menu.php ... I got errors.

Could you show me a snippet of how that code should look in the file? Do I have to replace the existing code or am I adding code? Sorry for the newbie questions.

David

Please Log in to join the conversation.

18 years 3 weeks ago #10995 by ben_emo
Yep you can see the full code to a working plugin through the source code repository for this project here:

forge.joomla.org/integration/viewcvs/viewcvs.cgi/plug_anjel/?root=anjel_cb_plugin&system=exsy1002

Cheers..

Please Log in to join the conversation.

18 years 3 weeks ago #11020 by geeffland
Replied by geeffland on topic Re:Preferred way to have public tab switchable?
Access denied through the posted link

CB3PD Developer - CB Connector (formerly phpBB Connector) plugin

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.208 seconds

Facebook Twitter LinkedIn