4

I am using plain text format. I want to create an input filter for when a user enters #15, it should be converted to a link pointing to the post #15. I want to do this for the Statuses (Social Microblog) module. The link of an individual status is like this: https://www.example.com/statuses/15.

Just for your reference, I found a snippet. It is specifically for nodes though, which was meant to be used with custom filter module.

My question: How to create such filter for statuses?

3 Answers 3

2

Take a look at the Custom Filter module.

This module allows you to create content filter using regular expressions. Instead of creating a new module for each filter you need, now you can easily create and organize your own filters. Your filter will appear in the input format configuration page.

If you want to do it yourself in a custom module, you can implement hook_filter_info

5
  • I know about the module, but the question is, how to do it? I do not know what code to use.
    – Umair
    Commented Apr 24, 2017 at 16:45
  • 1
    Read the module's documentation: drupal.org/node/210551
    – Elin Y.
    Commented Apr 25, 2017 at 7:46
  • I have read it 2 times before, but do not understand
    – Umair
    Commented Apr 25, 2017 at 16:49
  • Then you should open a support request on the module's issue queue: drupal.org/project/issues/customfilter or you ask another explicit question on what you cannot understand.
    – Elin Y.
    Commented Apr 26, 2017 at 12:57
  • What would you suggest after seeing this drupal.org/node/210555#comment-2684916
    – Umair
    Commented Apr 27, 2017 at 10:08
0

The Linkit module almost does what you want:

https://www.drupal.org/project/linkit

handbook:

https://www.drupal.org/node/2647538

The user starts typing the title and gets the link. No need to remember any number or internal path structure.

1
  • Its description says that it is for entities. My question is about statuses, which is not an entity
    – Umair
    Commented Apr 14, 2017 at 17:29
0

The Examples module has code for how to implement your own drupal "filters" (in your own module).

https://api.drupal.org/api/examples/filter_example%21filter_example.module/group/filter_example/7.x-1.x

Use them in a custom "text format" for your statuses.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.