Invision Community 4: SEO, prepare for v5 and dormant account notifications Matt November 11, 2024Nov 11
Posted October 1, 20177 yr Hello! What's a reason to convert \IPS\Helpers\Table to a string? In some places I see something like this: \IPS\Output::i()->output = (string) $table; /* or */ \IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'group' )->template( (string) $table ); Can you please avoid converting to a string? It will allow us to hook into a method and change something in the table without touching original code. So, for example, let's test this code: When you convert $table to a string we can do nothing with it: When you don't convert it, then we can easy change something we need: In the second case we stay original code untouched, that is better than replacing a whole method.
October 2, 20177 yr in your second example: \IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'group' )->template( (string) $table ); printing/echoing of \IPS\Output::i()->output will return a string any way, even if $table wasn't being casted to a string, cause the template would've done that if they did {$table|raw} inside the template. however your first one, i could see there isn't a need to cast to string. however, i would ask, is there no other way to hook into what you need, before that point?
October 3, 20177 yr What are you trying to accomplish exactly? Typically we want the data as a string, which is why we cast it.
October 3, 20177 yr Author Add a new filter option and new fields to the advanced search 13 hours ago, CodingJungle said: cause the template would've done that if they did {$table|raw} inside the template But we can hook into that template and change $table in the template's PHP method
October 3, 20177 yr Author 13 hours ago, CodingJungle said: however, i would ask, is there no other way to hook into what you need, before that point I'm not actually sure, but I think there's not.
Archived
This topic is now archived and is closed to further replies.