Jump to content

New text formatter plugin


Recommended Posts

I was trying to do a custom TextFormatter, which takes custom-formatted textarea, does double expolde and returns array with my values, so instead of parsing my special fields in template, I can use straight values (it also seems to be very nice idea to do with PW workflow)

FIELD:

  test:value1
  test:value2

upon loading the page, following array should be returned:

  [0]=>
    (k: test, v: value1)
  [1]=>
    (k: test, v: value2)

So I took one of the Textformatter plugins, created /site/modules/Textformatter/ directory and added the copied (and modified) plugin in there. After refreshing the modules, my plugin isn't added in  the 'Textformatter' group, and also I can't select it in the text formatter dropdown.

I don't have access to it right now, but it was the NLBR formatter, and what I did:

  • changed module information
  • modified format function
  • I basically took ther string input, did double explode (\n and :) and one trim and returned the resulting array as the modified &$str

What to do/how to create new textformatter plugin? Thank you!

Link to comment
Share on other sites

To answer my own question:

It seems, that Textformatter modules are added to the dropdown menu in field edit page if they are categorized as 'textformatter' modules. And it's categorized via first camel cased word in the name of the module (its class).

So there.

Link to comment
Share on other sites

This is correct with both Textformatter and Process modules: they need to follow a consistent naming convention. This is just so that PW can filter them by name. Glad you got it working.

Link to comment
Share on other sites

I feel that the fact, that Modules are grouped via first word (if camel case is used) should be stated in the API; It's very important to have this convention, so the organisation of the modules makes any sense; But how can developers follow this convention if it's nowhere stated?

:)

Link to comment
Share on other sites

It'll be stated once the modules documentation is complete. :) Though I'm not yet sure it'll stay that way. I might change the loader to just look at what classes they implement rather than the naming convention... not yet sure. What do you guys think?

Link to comment
Share on other sites

Okay, if it was on me, I would create like 5-10 logical groups (admin, textformatter, frontend, backend) and allowed developers to add this as integer index. But that's only my first idea, there is no time to conceptualize that right now :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...