spierala
spierala

Reputation: 2699

silverstripe shortcode return dynamic template

I followed this instruction to be able to include a variable in the Content Field (HTMLEditor) of a Page - so that the variable can be replaced with other content: http://www.balbuss.com/mini-introduction-to-shortcodes/

I want to display a list of dataobjects within the $Content.

Sadly the DummyHandler in the instruction is static. So I can´t access the Controller in it, to let him do something (generate the list.)

Is there a solution to access the controller in a static function or maybe is there another better way to put a variable in the $Content.

Thx, Florian

Upvotes: 0

Views: 307

Answers (1)

jfbarrois
jfbarrois

Reputation: 989

Controller::curr() is probably what you are after? To use in conjunction with Controller::hasCurr(), as no controller would mean an error when using Controller::curr()

See https://github.com/silverstripe/sapphire/blob/3.0/control/Controller.php#L384

Upvotes: 1

Related Questions