User Defined Tab Titles

17 years 7 months ago #21480 by Thornbrand
User Defined Tab Titles was created by Thornbrand
I’ve seen this brought up in several sections, but felt this was the most appropriate place to post – if not, my apologies. I have almost no php experience, so I’m almost embarrassed to show what I have working. Honestly, I’m amazed this works at all; nonetheless the end result demonstrates what I think would be a great simple module/feature for development.

I’m also hoping for some guidance, a better approach, or even a more “proper” interim solution (…read hack) than I have in place now.

I was looking at the “creative tab” idea, which suits the site I’m developing very well, but I wanted the user to be able to title their own tabs as well.

Here’s what I’ve done…
  1. Create a new tab. Set the title to “_UE_TAB_ONE” and publish it.
  2. Create a new field and assign it to “_UE_TAB_ONE”. Type: “text field”, Name: “tabonetitle”, Title: “Tab Title”, Show on Profile?: “No”, Publish it.
  3. Create a new field and assign it to “_UE_TAB_ONE”. Type: “Editor Text Area”, Name: “taboneeditor”, Title: “_UE_EMPTY”, Show on Profile?: “Yes”, Publish it.
  4. In default_language.php (or appropriate language file) add the line “DEFINE ('_UE_EMPTY','');”
  5. In comprofiler.html.php I added two database queries:

The First immediately after:
[code:1]
function userProfile($user, $option,$submitvalue) {
global $database,$my,$ueConfig,$_REQUEST,$_POST,$_PLUGINS, $mainframe;

/******************************
User Tab Title
******************************/
$query = "SELECT cb_tabonetitle FROM #__comprofiler WHERE id = ". $user->id;
$database->setQuery( $query );
$cb_fieldvalue = htmlspecialchars($database->loadResult());
if (empty($cb_fieldvalue))
{
DEFINE ('_UE_TAB_ONE', 'My Tab');
} else {
DEFINE ('_UE_TAB_ONE', $cb_fieldvalue );
}
/*****************************/[/code:1]

The Second immediately after:
[code:1]
function userEdit( $user, $option, $submitvalue, $regErrorMSG=null )
{
global $database,$ueConfig,$_REQUEST,$mosConfig_live_site, $mainframe;

/******************************
User Tab Title
******************************/
$query = "SELECT cb_tabonetitle FROM #__comprofiler WHERE id = ". $user->id;
$database->setQuery( $query );
$cb_fieldvalue = htmlspecialchars($database->loadResult());
if (empty($cb_fieldvalue))
{
DEFINE ('_UE_TAB_ONE', 'My Tab');
} else {
DEFINE ('_UE_TAB_ONE', $cb_fieldvalue );
}
/*****************************/
[/code:1]

The result...

The user sees all of their usual tabs as normal until they edit their profile. When they edit their profile they see an extra tab titled "My Tab". This tab contains the field to name their new tab.

If they name the new tab and add text to the editor text area, it shows up on their profile view with the Title they've choosen and the content they've entered. They can rename the tab at anytime by editing their profile, or make the new tab disappear by simple deleting everything in the text editor.

I know this is crude, and a hack - but if anyone would care to throw in their two cents I'd appreciate it.

Regards,
Thornbrand

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.125 seconds

Facebook Twitter LinkedIn