my posts have body text , in this texts i put short code like , Now i can find 2 arguments in my text (gallery and 2) i want to call Dynamically a function (gallery) in my view and it is calling a element (gallery id = 2) like this :
app/view/posts/index.ctp
findshortcode($posts[Post][Body]); // this function find short code and call his name like gallery(2)
//my problem is :
function gallery($id = null){
$this->element('gallery', array('galleryid' => $id), array('plugin' => 'gallerys'));
}
What you have there does not make a whole lot of sense, and the way you are describing doing it is not the Cakish or MVC way of doing things. But I think I get your question and will explain to you the way you want to do it.
What you need to do is this… Do all the logic from inside the controller… then send all finished variables to the view for display…