bot_write_tab_customize
One thing that always buggled me is the rigidity of the textpattern “write” tab.
Once I had to do a site containing – between all other sections – a blog and a movies catalogue.
Well, I knew I could manage all items for the catalogue section (i.e. “author”, “actors”, “plot”, “year” and so on) using a lot of custom fields (with the help of glz_custom_field of course) but the problem was these fields were totally out-of-place when writing a blog post. And I still ended with an incredibly long left column in the “catalog” section. And furthermore I didn’t need a body textarea here…
All this problems could be partially solved with the help of some clever plugins such as sed_section_fields and ied_hide_in_admin but there was still somemething missing.
To make it short I wrote this plugin which allows to rearrange and style items in the write tab, hide them on a per section basis and remove sections from the “write” tab sections dropdown. Used alone or togheter with the above mentioned plugins can really ease txp admin customization.
Note that the rearrange capability is mainly intended to be an intermediate step in the “write” tab customization process. It takes care of page elements that cannot be moved or targeted with simple css. You are so encouraged to fine-tune your customization by modifying the “textpattern.css” file.
Features
- Single items (custom fields, body, excerpt etc.) can be moved around relative to other single items
- Columns can be moved around relative to other columns
- Columns and single items cannot be moved relative to each other to avoid messing with the underlying html structure
- Items can be hidden on a per section basis
- Advanced preferences allows for multiple items hiding and class attribution, speeding up the customization process if a lot of custom fields are set.
- Sections can be removed from the “write” tab sections dropdown (for static sections like “about us” or “search”)
- A custom css class can be set for each item. This let's you define classes for items that normally couldn't be targeted with simple css (i.e. a p surrounding a specific custom field and his label - if you are using glz_custom_fields). This is useful also to quickly apply styles defined in your textpattern.css file. This feature has now a reduced importance with txp 3.0 since a lot more page elements can be directly targeted by css.
- Javascript code can be set directly throught the plugin interface. Particularly useful for use with an external jquery plugin and in conjunction with the ability to add a css class to any item on the page. The script will be executed only in the “write” tab
- glz_custom_fields compatible
A simple example
Suppose you want a giant coloured round-cornered section drop-down as the first item at the top left corner.
Quite easy: first set the rule “section dropdown before textilehelp”, then add one (or more) custom class to the item, let’s say “big rounded” (note multiple classes can be set). Now write some rules in your textpattern.css like:
big{background:#c00 url(images/my_background.gif); color:#fff; font-size:14px; font-weight:bold;}
and finally, if you want to use a jquery plugin for the rounded corners, write something like this in the js box:
<script type="text/javascript" src= "../js/your_jquery_rounded_corners_plugin.js"></script> <script language="javascript" type="text/javascript"> $(document).ready(function() { $("rounded").your_jquery_rounded_corners_plugin(); }); </script>
…and you are done.
The same principle applies if you want to apply other js behavieur (i.e. collapsible menu): first set a class for the elements you want to target and then write the appropriate Jquery (or plain js) code.
Another example
Textpattern 4.3 brought a lot of cool enhancements to the "write" tab but also a few drawbacks.
On the 'enhancement' side almost every item has now an id or a class. This means a snappier jquery execution and, above all, the possibility to hide these elements with simple css. For these reason I highly reccommend - if you want to hide an item in each section - to set a rule directly in your textpattern css file.
For example:
.override-form {display:none;}
Is a lot more efficient than hiding the item in each section using this plugin.
Unluckily there are some little drawbacks in the way the page is designed (IMHO). I'm referring to the several collapsible groups which crowd the 'write' tab.
The issue here is while you can easily hide a group label (well, actually it isn't an html label but an h3) with css, this may lead to trouble if the group is already collapsed. In this case a user will not be able to expand it anymore being there nothing to be clicked.
Of course this is nothing dramatic and can be fixed inserting a tiny jquery rule in the js box. Something like:
<script type="text/javascript">
$(document).ready(function() {
$(".toggle").show();
});
</script>
will keep everything expanded so you can safely hide any label with css (in your textpattern.css file).
Naturally you can also choose to apply this rule only to certain groups (separated by commas) like:
<script type="text/javascript">
$(document).ready(function() {
$("#image.toggle, #custom_field.toggle").show();
});
</script>
Notes
- The order in which the rules for moving items are inserted does matter. Rules execution goes from top to bottom so in case the sequence gets garbled it’s advisable to delete all and start over
- Class names must be inserted without the dot
- In a standard txp installation it isn’t necessary to call the Jquery library (it’s loaded by default by txp)
Instructions
Once inatalled and activated visit: “extensions” > “bot_wtc”. Choose an item, choose “before” or “after” and choose another item.
Hi Roger,
sorry again for not having answered in so long, this is really a busy period for me.
Now regarding your question, if I understand correctly your request can be also reformulated this way:
Can be the item rearrangement tied to the “override form” dropdown instead of the “sections” one?
The answer is yes, but I don’t see any real advantage in doing so. At least for the way I usually organize sites. That said I understand you may find your approach more productive.
If you have some php knowledge you can tweak the plugin to do what you want. If you agree with the method I mentioned before you must replace each reference to the sections dropdown to the “override form” dropdown. This should be not too difficult once you understand how the code works.
If I had more free thime I could be more helpful but sadly this is not the case :( anyway thank you for your suggestion: any improvement idea it’s always appreciated, even when I don’t agree.
redbot | 9 July 2011 #
My bad! When I re-read my comment, it made little sense to me either! What I was attempting to say is that the plugin would be more flexible if it wasn’t tied to the write tab’s section drop-down. I think if it created it’s own user defined select list in the write tab area, it would free up sections for taxonomy purposes.
The example I gave goes like this –
> I use your ‘amended’ plugin (and glz Custom Fields) to rearrange the write tab to accommodate an easy video upload interface.
> In the plugin options panel, rather than associating / saving this configuration to a TXP section, I create a name / title for it. i.e Video
> When I go to the write tab, I see in one of the columns a new select list that lets me choose ‘video’. When I select it, the write page rearranges according to how I set it up.
> Now I can evoke the newly arranged write panel regardless of what section I want to place the article in.
If this was possible, TXP would truly be one huge leap closer to Custom Content Types. It would also be handy if the ‘amended’ plugin created a new <txp:tag> called, lets be frivolous, <txp:content-type name=“video”> that could call all articles created under that write tab configuration.
I hope this makes more sense! I also think you could / should fund this sort of development in-line with the GLZ CF method!
Either way, I just realised I forgot to thank you for the Plugin as it stands. It’s still pretty damn awesome! Cheers!
roger | 25 May 2011 #
Roger and John,
first of all sorry for the late reply, I missed Roger’s comment completely.
That said I’m not sure I understood what both of you are asking for. This plugin is intimately related to the txp “write” tab so using it on another tab would mean writing a completely different plugin from scratch.
Would you mind explaining better what you are trying to accomplish?
redbot | 25 May 2011 #
Agree with Roger. Freeing this module from the article’s section, would make it much more flexible.
john | 23 May 2011 #
Would it be possible to amend your plugin to use, say, a custom field radio select list to determine how to display the write page as oppose to the articles section?
Many of my sites have different types of content i.e blog posts, videos, reviews etc, and my urls look like this: mysite.com/music/video/article-name or mysite.com/music/blog/article-name. I mite also want to display all videos via mysite.com/videos.
I’ve avoided txp until now because it can’t natively do this. Your plugin lets me get most of the way there, but I can’t figure out how to achieve the url structure I want whilst using your plugin….
Any ideas?
Roger | 11 May 2011 #
Thanx Kreeltje, I’m glad you found it useful.
redbot | 27 February 2011 #
This Rocks!!
Thank You!
Kreeltje | 23 February 2011 #