XF 2.2 Manipulate snippet?

Robert9

Well-known member
I have a wonderful bbCode with a calculation.
When I use snippet the bbCode-function is not working.
a)Is there a chance to tell snippet not to touch this specific bbCode?


b)Is there a chance to add char after a certain bb-Code?

Example:
b]This is a titel[/b
Haha, this is a text

A snippet looks like
This is a titel Haha, this is a text

Really ugly! It should be

This is a titel - Haha, this is a text

Means, I need a " - " after the b]Titel[/b <=
 
Assuming you're using the snippet template function since you haven't shared any code. This function will strip BBCode if you pass the stripBbCode or stripQuote options. You can omit those options to retain all BBCode, or manipulate the string prior to passing it to that function if you did want to strip it afterwards. You can also use the bb_code_snippet template function to render the snippet as BBCode.
 
Thank you, but i dont understand what to do
Here the two problems again:

bbCode year takes a year and calculates something, result is an integer.

This happens in year [year]2023[/year]

shows maybe

This happens in year 15203.

When xf or add-ons use snippet, people will see:

This happens in year 2023

but they should see

This happens in year 15203.

What I want to do is a global order for snippet to transform/replace/calculate/use this specified bbCode year.
b]bold text[/b and heading]title[/heading and all other bbCode should be removed, but never my bbCode year.


Equal problem:

heading=1]This is my title[/heading
Here is my text

should be show as

This is my title - Here is my text



I need to inject the right place to say:

hey, bbCode-remove function!
When bbCode year comes inside, never touch it!
When heading comes inside, replace the /heading with " - "


Result would be
This happens in year 15203.
(from: This happens in year [year]2023[/year])
and

This is my title - Here is my text
(from:
heading=1]This is my title[/heading
Here is my text


Somewhere must be a function working like:

if you find [something](.*)[/something]
then show (.*) for all {something}

and i have to change this to:

if you find [something](.*)[/something]
then show (.*) for all {something} as long something is not "year";
and when you have heading, then
add " - " to (.*)
 
There is no built-in option to strip BBCodes selectively. You could write a custom method to accomplish this (see \XF\Str\Formatter::stripBbCode), or perhaps pre-process the string and replace your BBCode tags with custom delimiters, strip the remaining BBCode, swap the delimiters back, and then use bb_code_snippet to render them.
 
Top Bottom