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
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
    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 that you have read and understand our privacy policy and code of conduct.

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