Open QuentinPi opened 9 years ago
Get 'fm_bbcode.decoda_manager' service in your controller, and use it like here https://github.com/helios-ag/FMBbCodeBundle/blob/master/Templating/BbcodeExtension.php#L79
Thanks a lot ! It works but I have a problem with the quote and code tags. When I use the bbcode cleaner, it renders nothing !
EDIT : I have also a question about the emoticons, is it possible to configure them with a emoticons.php file like in decoda ? (https://github.com/milesj/decoda/blob/master/src/config/emoticons.php) I read your doc and I call the php file in the config.yml but it doesn't work. I think a .yml is expected. I found a solution for that, by changing the EmoticonHook.php
problem with the quote and code tags
If you apply bbcode_clean, inside twig template, did this filter strip code/quote tags from your string?
About second question: this hook expects yml configuration for emoticons file, another way, is to register custom hook, that will look for your emoticons php file
About the first question, yes, the filter strips code and quote tags but also the content. I discovered there is an option in decoda : stripContent, I turn it off and now it's perfect ! But I have a problem with the usage of bbcode_clean in a twig view : how can I pass a filterset string in parameter ?
The same way as bbcode_filter(filterSet) -> bbcode_clean(filterSet)
Good ! Your bundle is very powerful ! I have one more question... Does it exist a way to avoid line break with decoda manager ? In the decoda documentation, I see options like "setLineBreaks" or "setMaxNewlines" but it doesn't work in the config.yml...
Well, yes. Option setMaxNewlines is not available. But you can make a PR :) Opened issue #125
Hello @QuozPowa
@helios-ag has already responded very well to all questions but I would like to provide some clarifications.
I would like to use the bbcode_clean filter directly in a controller, without using any twig view.
You can also use the fm_bbcode.templating.helper
service (ref).
I have also a question about the emoticons, is it possible to configure them with a emoticons.php file like in decoda ? (https://github.com/milesj/decoda/blob/master/src/config/emoticons.php) I read your doc and I call the php file in the config.yml but it doesn't work. I think a .yml is expected. I found a solution for that, by changing the EmoticonHook.php
Both PHP and Yaml configuration files are supported (ref). It uses a delegated loader to use the good one. On PHP format the file must return an FM\BbcodeBundle\Emoticon\EmoticonCollection
it is because the emoticons.php
file like in Decoda does not work. It is possible to write a loader that support emoticons configuration like in Decoda.
Well explained @alquerci, thank you!
Yes thank you everyone ! I managed to do what I wanted. Your bundle is very very useful ! :+1:
I have again another question ! Do you know if it's possible to get the EntityManager in a filter file ?
Can you explain what goal do you plan to achieve with this, and btw what do you mean under 'filter file'?
Sorry, I just realize that it is a decoda file (https://github.com/milesj/decoda/blob/master/src/Decoda/Filter/QuoteFilter.php). Actually, I would like to check the author attribute (quote tag) in the database in order to display a link. I can add my own parse method in this filter but the EntityManager isn't available.
Hello @QuozPowa,
There are many ways to achive that the main goal is to extends the Decoda\Filter\QuoteFilter
class:
* override fm_bbcode.decoda.filter.quote.class
configuration
* create a new filter for exemple enhanced_quote
or what you want, doc
IMHO injecting EM even in filter isn't a good idea, i think this can be achieved with simpler solution, like providing route to user profile.
Thanks you, I managed to do it :) I meet a new problem with special spaces and emoticons, I will create a new issue !
Hello, I have a new question about your bundle ! I would like to use the bbcode_clean filter directly in a controller, without using any twig view. I think there is a proper way to call it in a Symfony controller...