Keyword

Adding to Extra Field options in admin

  • Alan Campbell
  • Alan Campbell's Avatar Topic Author
  • Offline
  • Junior Member
More
7 years 5 months ago #162507 by Alan Campbell
Adding to Extra Field options in admin was created by Alan Campbell
Hello,

Is it possible to add an additional option to the extra field settings?

I made a horrible hack to add a tooltip to extra fields (essentially explaining what the user is to enter, beyond just the name). It's really not great!

I hada look at the example plugin but unsure where to go next. Can't see any definitive documentation on plugin dev which could a novice like me!

Cheers!

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 5 months ago #162515 by Krikor Boghossian
Replied by Krikor Boghossian on topic Adding to Extra Field options in admin
Hello Alan,

Can you elaborate a bit, I am trying to understand the entire issue,

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • Alan Campbell
  • Alan Campbell's Avatar Topic Author
  • Offline
  • Junior Member
More
7 years 5 months ago #162521 by Alan Campbell
Replied by Alan Campbell on topic Adding to Extra Field options in admin
Hello!

Apologies for my brevity.

I want to add tooltip-style explanations to the Extra Fields name labels shown when adding an item from the frontend. Similar to those that K2 has when you hover over options in the admin area.

I assume this can be achieved via a plugin. However, I'm not sure which events (e.g. onK2AfterDisplayContent) and which class to extract the data from.

Alan

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

  • Alan Campbell
  • Alan Campbell's Avatar Topic Author
  • Offline
  • Junior Member
More
7 years 5 months ago #162522 by Alan Campbell
Replied by Alan Campbell on topic Adding to Extra Field options in admin
Hello!

Apologies for my brevity.

I want to add tooltip-style explanations to the Extra Fields name labels shown when adding an item from the frontend. Similar to those that K2 has when you hover over options in the admin area.

I assume this can be achieved via a plugin. However, I'm not sure which events (e.g. onK2AfterDisplayContent) and which class to extract the data from.

Alan

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 5 months ago #162531 by Krikor Boghossian
Replied by Krikor Boghossian on topic Adding to Extra Field options in admin
Since you can render each extrafield on its own, you don't really need a plugin or anything special.

In the loop do not render any fields with the id matching that of the fields used for the description, and render them explicitly when needed with the appropriate HTML code.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • Alan Campbell
  • Alan Campbell's Avatar Topic Author
  • Offline
  • Junior Member
More
7 years 4 months ago #162963 by Alan Campbell
Replied by Alan Campbell on topic Adding to Extra Field options in admin
Dear Krikor,

Many thanks for your reply and sincere apologies for the delay in mine.

Although I have made a dirty hack using the template system to show these "tooltips" in the past, I feel this is less than ideal as will be broken whenever templates are updated or if the label is pulled by a page that doesn't use the template with the hack. This hack involved including the tooltip content in the extra field label and using regex to extract it and add the HTML required. Eg "label tooltip" would be rendered with the "label" being shown as normal and the"tooltip" separately.

I was wondering whether I could use a plugin to have an additional option to the admin interface for a tooltip so that sick a Jack would not be required. Then the tooltip could be only shown on the front end edit screen or a different one shown when the article is being read. Eg on front end editing for an extra field with label "book" you may want a tooltip saying "please enter book title and subtitle in capitals" and on the reading view you'd want it to show "Tuttle of book including subtile".

Basically I'm just trying to improve user friendliness of the front end editing.

Alan

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 4 months ago #162967 by Krikor Boghossian
Replied by Krikor Boghossian on topic Adding to Extra Field options in admin
No worries Alan :)

Define how dirty the hack is. You can use a custom jQuery script to prepend/ append text. This is not dirty at all.

Keep in mind that you can override the itemform.php file as well and print your own data or you can use the extrafield headers to hold the instructions you need.

I am a bit lazy so I would keep the form unaltered in case anything changes in the future releases (less maintenance). Since tooltips can be done with pure CSS, I would use jQuery to alter the markup and place the tooltips in the correct labels. Seems like a hassle but you will save a lot of time in maintenance, plus you can alter it any way you want it to.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 4 months ago #162968 by Krikor Boghossian
Replied by Krikor Boghossian on topic Adding to Extra Field options in admin
No worries Alan :)

Define how dirty the hack is. You can use a custom jQuery script to prepend/ append text. This is not dirty at all.

Keep in mind that you can override the itemform.php file as well and print your own data or you can use the extrafield headers to hold the instructions you need.

I am a bit lazy so I would keep the form unaltered in case anything changes in the future releases (less maintenance). Since tooltips can be done with pure CSS, I would use jQuery to alter the markup and place the tooltips in the correct labels. Seems like a hassle but you will save a lot of time in maintenance, plus you can alter it any way you want it to.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • Alan Campbell
  • Alan Campbell's Avatar Topic Author
  • Offline
  • Junior Member
More
7 years 4 months ago - 7 years 4 months ago #162981 by Alan Campbell
Replied by Alan Campbell on topic Adding to Extra Field options in admin
Dear Krikor,

It's really quite dirty!

See below - all done in hacky server side template code:
<?php 
$wholeLabel = $extraField->name;
								
preg_match('/\[\[(.*?)\]\]/',$wholeLabel,$captionLabelArray);
if($captionLabel = str_replace(']]','',str_replace('[[','',$captionLabelArray[0])))
{

	$beginningPos = strpos($wholeLabel, '[[');
	$endPos = strpos($wholeLabel, ']]');
	$textToDelete = substr($wholeLabel, $beginningPos, ($endPos + strlen(']]')) - $beginningPos);
	$mainLabel = str_replace($textToDelete, '', $wholeLabel);
?>
	<strong><label for="K2ExtraField_<?php echo $extraField->id; ?>"><?php echo $mainLabel; ?></label></strong>
	<span class="ACExtraFieldCaption hidden"><?php echo $captionLabel; ?></span>
	<?php } else { ?>
	<strong><label for="K2ExtraField_<?php echo $extraField->id; ?>"><?php echo $extraField->name; ?></label></strong>
<?php } ?>

So, pretty sloppy.

I hadn't actually considered doing it via JQuery. Maybe that's the way to go.

Alan
Last edit: 7 years 4 months ago by Alan Campbell.

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 4 months ago #162989 by Krikor Boghossian
Replied by Krikor Boghossian on topic Adding to Extra Field options in admin
On a (also dirty) sidenote, you can also use explode() if you are using a certain pattern for your labels eg: label | text for tooltip.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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


Powered by Kunena Forum