Avner

Custom Custom Fields

Vote 0 Votes

I would like to know if there is a developer on this forum that has ever implemented or developed a system where the following scenario is described in the documentation:

Custom Custom Field Types:
-----------------------------------------
Movabletype Documentation here:
http://www.movabletype.org/documentation/developer/custom-custom-field-types.html

Sometimes the choices available are not adequate, and a developer would like to define a new form element or custom field type. For example, suppose you want to allow authors to select a different sidebar (or "widget set") from a pull down menu for each entry and/or page? Such an option doesn't exist by default.

The following example will show how to create a custom "Custom Field Type" that a user can use to associate with a page or entry. The custom field could then allow them to select from a pull down menu the widget set that they would like to have associated with the current entry or page.
-----------------------------------------

If would be very powerful if this is a standard implementation in MT.

Reported on Movable Type 5

6 Replies

| Add a Reply
  • Hi Avner,

    For this very case of the widget set and the pull down menu, you could create a "Drop Down Menu" custom field for the object "Entry" and eventually the object "Page".

    Then, you could check against the output of that custom field and include a different widget set for each specific value from the "drop down menu".

    The idea is that you could combine custom fields with the template tags logic and create anything you need for your project.

    Kind Regards,
    Mihai Bocsaru

    ----------------------------------
    Daily Movable Type Consultant

    Web Development
    Movable Type Consulting
    Six Apart Partner

    http://www.pro-it-service.com/
    ----------------------------------

    Movable Type Demo
    http://www.movabletypedemo.org/

  • Mihai, thanks for your quick response.

    From what I understand you are saying, this can be done without creating an additional plugin, like the above MT documentation at the link suggests.

    So what I need to do is create a custom field, and use the Widget Set names as options for the drop-down menu, and then add the following code somewhere in a template or module.

    ---------
    <mt:If tag="page_sidebar" eq="Sidebar 1">
    <$mt:WidgetSet name="Sidebar 1"$>
    </mt:If>
    <mt:If tag="page_sidebar" eq="Menu Only">
    <$mt:WidgetSet name="Sidebar 2"$>
    </mt:If>
    ---------

    I have actually done this, so a user can select a new page's style like this, based on a predefined template. That works quite well.

    This will probably also work then for sidebars, or anything else for that matter.

    Let me know if I am not on the right track.
    Thanks!

  • Yes, that is correct :)

    You're welcome!

  • Hi Avner,

    Mihai is correct, if you have a Movable Type Pro license which comes with the Custom Fields plugin. If you are on MTOS, the free distribution, then perhaps the best solution is my free "TemplateSelector" plugin.

    https://github.com/Hiranyaloka/mt-plugin-template-selector

    The TemplateSelector plugin allows you to define a preselected list of templates which can then be chosen from within an Entry or Page. The name of that template is then stored in the TemplateSelector tag, which you use in your templates in the context of an Entry or Page.

    The TemplateSelector plugin also comes with a "WidgetSelector" and "WidgetSetSelector" tags, which work the same as the TemplateSelector tag. You choose individual widgets or widget sets from a pulldown menu in the edit Entry or Page panels

    BTW, Template Selector is compatible with MT4 Pro also.

    I have only tested the plugin on MT4, with the (currently) required ConfigAssistant plugin (which is not MT5 compatible).

    https://github.com/openmelody/mt-plugin-configassistant

    Eventually I'll either remove the ConfigAssistant dependency or test it with a CA fork that runs on MT5.

  • Mihai, thanks for the support, and Rick, good to know about your TemplateSelector plugin. It will be great to get this working on MT5. I run a few test installations, but also have some clients in MT Pro.

Add a Reply

If you need to share template code, replace all the "<" signs with "&lt;" or use this utility.

Forum Groups

code.sixapart.com

141 498

Last Topic: Action Stream for LinkedIn by michael webster on Jan 10, 2013

255 908

Last Topic: Comments not working on old MT (4.2) blog by phillio on May 8, 2013

1874 6646

Last Topic: Body HTML editor sucks big time by Shahzad on May 13, 2013

89 311

Last Topic: Seeking explanation of files and folders by CosmicKnight on Feb 23, 2013

1523 5507

Last Topic: Blog from 2006 still sends spam to my account and I can't access it by liltayinchina on May 14, 2013

743 3151

Last Topic: Installation Problem by Alex L on Apr 2, 2013

90 336

Last Topic: HELP! I need to 301 over 100 urls on my site via htaccess by justin on Feb 22, 2013

193 801

Last Topic: Deleting Revision History by Will Haynes on Mar 16, 2013

220 726

Last Topic: Cookies are being overwritten by David on May 11, 2013

28 97

Last Topic: Movable Price by joe22 on Jan 10, 2013

52 222

Last Topic: Movabletype.org is in bad need of a redesign by Caio on May 11, 2013

65 249

Last Topic: Expanding new rich text editor and implementing table function by Takeshi Nick Osanai on Jul 30, 2012