I’m using the “publish_form_field_unique” hook to make a new custom field of the type “markitup”. This extension allows one to disable (and re-enable) it with a click right on the publish/edit page, rendering just the plain text field - but the formatting menu isn’t there, even when users select to show the formatting menu.
It looks like when I use publish_form_field_unique it is a completely blank slate - I can put anything I want there, without EE adding any of the normal stuff. What If I want some of the normal stuff added in there - such as the formatting menu? Is there a simple way to return the default formatting menu (like what would be returned if the field was a regular textarea)?
I’m really looking to add just a “normal” textarea field, but of a special “markitup” type (essentially replicating the “textarea” field type but with a different name) so that Markitup will only replace textareas in fields of the type “markitup” and leave all others alone.
To give you an idea of what I have now, this is my function:
Note: My code is getting mangled no matter how I post it in here, but you’ll get the idea.
function publish_form_field_unique( $row, $field_data )
{
// Check if we're not the only one using this hook
$r = ($EXT->last_call !== FALSE) ? $EXT->last_call : "";
if($row["field_type"] == $this->type)
{
$r .= '<a href="#field_id_%27.$row" class="toggle"><span>Disable '.$row["field_fmt"].' markItUp!</span></a><br clear="all" >';
$r .= '<textarea dir="ltr" name="field_id_'.$row['field_id'].'" id="field_id_'.$row['field_id'].'" rows="'.$row['field_ta_rows'].'" cols="90" class="markitupfield '.$row["field_fmt"].'">'.$field_data.'</textarea>';
}
return $r;
}
And it is returning this:
Obviously, if you look at the markup for a regular textarea field, there is a lot more in there than what you see here (formatting menu, table wrapped around the textarea, etc). I’m just looking for an easy way to replicate a textarea field type, with all the extra padded wrappers, etc and the formatting field, but with a field type of “markitup”. Any ideas are totally welcome.
Moved to Extensions: Technical Assistance by Moderator
After spending way too long trying to decipher what the devil is going on in cp.publish.php, I ripped out some stuff (the text_formatting_buttons function) and have made my own dropdown for the text formatting, underneath my Markitup custom fields. The only issue is that if I change the selection, it doesn’t save. I’m pretty sure I’m missing a hook - which I can’t seem to find browsing through the hooks. If I have a formatting dropdown for my field, and I want to save a change to the formatting - do I need a hook other than publish_form_field_unique, and if so, which one?
Programming questions for extensions is beyond the scope of Technical Support. I’m going to move it to a more appropriate forum.
I do think at some point, programming questions for extensions will need to become part of EllisLab’s repertoire, because the documentation for hooks is really lacking and there really aren’t any organized, concrete examples of how or why one might use a hook - other than to open existing add-ons and hope that the author has done something that you can study and emulate.
For example, the documentation for the hook “publish_form_end”. The full description is: “Allows adding to end of submission form”. Adding what? Anything?
These sorts of questions are one reason I’m starting devot:ee (devot-ee.com) - because there really needs to be a stronger resource for developers, even if the resource is written by a struggling developer!
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.