FluidTYPO3 / vhs

TYPO3 extension VHS: Fluid ViewHelpers
https://fluidtypo3.org
Other
190 stars 229 forks source link

Missing example usage for string contains #1718

Closed BennyAlex closed 2 years ago

BennyAlex commented 3 years ago

Hello, on the https://viewhelpers.fluidtypo3.org/fluidtypo3/vhs/5.0.1/Condition/String/Contains.html site is no usage explained.

I tried <v.condition.string.contains haystack="{title}" needle="online"> is online! </<v.condition.string.contains>

But will always result in true.

vblanches commented 3 years ago

Maybe a bit late, but you had a syntax error on the closing tag:

</<v.condition.string.contains>

(Sould be </v:condition.string.contains> )

Hopefully you already figured it out, but that's the reason why it wasn't working properly ;)

cweiske commented 2 years ago

The documentation is generated from the viewhelper php source code. Please send a patch/pull request that adds the example in the classes' docblock.

NamelessCoder commented 2 years ago

Tested locally to confirm that then/else is triggered correctly in the ViewHelper. There was an issue in cases where haystack was an integer, this was fixed recently. If the case is that your haystack is an object, then depending on the exact object your condition may either always be true or always false. If necessary, you can cast your haystack input with haystack="{title as string}" (which would call __toString on the object if your input is an object).

As @cweiske mentioned you are more than welcome to open pull requests that add usage examples!