Textpattern tab manager

n: smd_tabber | v: 0.11 | f: /

Documentation for the Textpattern plugin smd_tabber by Stef Dawson follows this short message from our sponsor ;-)

Plugin list button Plugin download button Compressed plugin download button

smd_tabber

Create and manage your own TXP tabs/sub-tabs, populating them with any content you wish for your users. Content and CSS are controlled by regular Textpattern Pages/Stylesheets. Acts like a multi-user, multi-tab dashboard for your admin-side users.

Features:

  • Define new primary or secondary tabs in your menu hierarchy
  • Assign a Page and a Style to menu items
  • Two convenience tags allow you to add Edit links in your markup for quick access to edit the tab’s content

Author / credits

Written by Stef Dawson. Spawned from an idea by maverick, with thanks. Kudos to the feedback from the beta test team — maruchan and maverick — who put up with endless new versions a day until I got it right.

Installation / uninstallation

Requires TXP 4.4.0+

Download the plugin from either textpattern.org, or the software page, paste the code into the TXP Admin -> Plugins pane, install and enable the plugin. To uninstall, delete from the Admin -> Plugins page. The table containing the extra tab definitions will be removed but your tab Pages and Stylesheets will remain.

Visit the forum thread for more info or to report on the success or otherwise of the plugin.

Usage

Visit Admin->Manage tabs. When there are some custom tabs defined, the dropdown beneath the heading contains a list of all your tabs, grouped by their area. Choose one of the tabs to load it into the boxes below for editing. The boxes are:

  • Tab name : name of your tab as it appears to your users (case sensitive)
  • Sort order : an optional value you can assign to this tab that dictates the position it will occupy in your tab sequence. Tabs are sorted by this value before being slotted into the menu
  • Assign to area : select which primary-level tab (a.k.a. the “top row” in the Classic theme) your new tab will appear under. If you want to create a new one, type it in the adjacent box (case sensitive)
  • View privileges : select the user privilege levels that are allowed to see this tab. Default: current level of logged-in user. Note that ‘none’ is an option. This allows you to remove a menu from operation and ‘park’ it while it is being created/edited, without fear of anyone being able to see what you are doing. When you are ready to put it into production, simply reassign it to a regular user level
  • Page template : if you have defined at least one TXP Page (in Presentation->Pages) with the designated prefix (tabber_ by default) then you will see those pages listed here. Choose one to assign it to this tab. Click the adjacent Create or Edit link as a shortcut to Presentation->Pages
  • Stylesheet : if you have defined at least one TXP Stylesheet (in Presentation->Style) with the designated prefix (tabber_ by default) then you will see those sheets listed here. Choose one to assign it to this tab. Click the adjacent Create or Edit link as a shortcut to Presentation->Style

Interface notes

General

  • You need to reload the admin side after saving to see any changes
  • Area and Tab names are case sensitive: name them as you want your users to see the tabs
  • Publisher level accounts also have a [Preferences] link below the header
  • Using smd_faux_role is a good way to quickly switch user level so you can see the tab structures you have created

Tabs

  • Alongside the tab selector of any tab you are editing is a View link. Click to jump straight to the selected tab
  • Alongside the Tab name box of any tab you are editing is an [x] link. Click to delete the tab
  • The Sort order allows you to arbitrarily order the tabs without having to rely on inventive tab naming strategies. If all the sort boxes are left empty, the order is determined by the alphabetic order of the tab names
  • Tab names must be unique — even if they occupy different areas

Areas

  • Areas will appear to the right of the Extensions tab, in alphabetical order; they (currently) cannot be positioned. If you want something to stand out, attach it to the ‘start’ tab
  • Areas MUST have at least one sub-tab assigned to them to become visible

Pages and Styles

  • Pages and Styles must begin with your chosen prefix (Default: tabber_) to be selectable by the plugin. Change the prefix via the plugin’s Preferences
  • If you view the content of a tab that has no Page assigned, a default page will be used which contains ‘Edit Page’ and ‘Edit Style’ links
  • Pages and Styles can contain TXP tags and are parsed as if on the public side. But you don’t need a DTD/head/body/footer element here because they are supplied by the admin interface: you are just filling in the content between the menu and the footer
  • If you are using tags that automatically detect their context, you will probably have to manually specify the context when using those tags in admin-side pages

Preferences

Permit tabs to be managed by

By default the tab manager is only available to any user with a Publisher account. Sometimes you may want to strictly control who can or cannot add/edit tabs. If you wish to do this, select user accounts from the Permit tabs to be managed by list and hit Save. From that point on, only those explicit user accounts will be allowed access to the tab manager. Be careful not to lock yourself out :-)

Note that no restrictions are placed on who can edit the tab Pages and Styles: they are subject to TXP’s usual permissions structure so if you want to restrict access to these elements, choose suitable accounts for your users and tie them to the plugin’s prefs.

Page/Style prefix

In order to be assignable to a tab, your custom pages / stylesheets must begin with a defined prefix. Set the prefix here. Default: tabber_.

Parse depth

Most of the time, TXP’s parser takes care of nested tags nicely but in some rare instances you may have, say, {replacement} strings inside tags inside tags and the parser might not be replacing everything. In these cases you can increase the parse depth of smd_tabber so it can dive deeper into the nested tag tree. The default is one pass, but if you wish to increase it, do so using this value.

Public tags

<txp:smd_tabber_edit_page /> and <txp:smd_tabber_edit_style />

Renders a link to the Presentation->Pages or Presentation->Style tabs, respectively, with the current page/stylesheet loaded ready for editing. If the resource doesn’t yet exist the link will take you to an empty document. You must begin the name of your page/stylesheet with your chosen prefix (see prefs) for it to be picked up by the plugin.

Optional arguments:

  • name: override the default name. If you want to force the link to edit a particular Page/Stylesheet, specify it here, either with or without the prefix
  • title : the title of the link. Default: Edit page / Edit CSS, respectively
  • wraptag : the (X)HTML element (without angle brackets) to surround the link, e.g. wraptag="span". Without this attribute set, class and html_id will do nothing. Default: unset.
  • class : the CSS classname to apply to the wraptag. Default: unset
  • html_id : the HTML id attribute to apply to the wraptag. Default: unset

Dashboards and compatibility

There is nothing to stop you using other dashboard or menu management plugins with smd_tabber. But the open architecture of smd_tabber means that, with a bit of planning, you can probably replicate most dashboard/menu functionality and perhaps do even more with it. Here are some common things that other plugins provide and how smd_tabber can be used to deliver similar functionality:

  • lum_user_menu
    • although not as point n’ click, you could create a Page with a grid of shortcuts on it. You could define an smd_macro called ‘lum_cell’ that could take parameters to specify the icon, destination URL, etc. Calling that multiple times in your tab’s Page would render the menu grid. You could even wrap some cells in rvm_privileged tags to control who could see which icons
  • jmd_dashboard / sed_dashboard / aro_myAdmin
    • you can add your own tabs under the start tab
    • you can recreate the edit link functionality via an smd_macro, rsx_frontend_edit, chh_admin_tags, rss_article_edit, or even a TXP form with txp:yield
    • employ upm_textile for fine-grained Textile processing inside your Pages (it’s more robust than having to escape tags-in-tags with notextile. or ==). Alternatively, write your content in Articles and import them into your Pages with txp:article_custom
  • esq_admin_splash
    • again, smd_tabber can be told to reside on its own tab and you can write your help text in a tab Page with optional upm_textile support

If none of the above appeals, you can of course mix smd_tabber with other tab-making plugins but please be aware that each plugin does things in their own way and methods of manipulating menus vary greatly. Therefore, if you experience odd menu bar behaviour you may consider switching off various combinations of such plugins to track down what’s going on.

Changelog

31 Mar 11 | 0.10 | Initial public release
31 Mar 11 | 0.11 | Imported $pretext to prevent warnings when using article tags (thanks redbot) ; improved documentation clarity

Source code

If you’d rather dive in and out of functions, you’ll need to step into the view source page.

Legacy software

If, for some inexplicable reason, you need a legacy version of a plugin, it can probably be found on the plugin archive page.

Experimental software

If you’re feeling brave, or fancy skateboarding into volcanos, you can test out some of my beta code. It can be found on the plugin beta page.