⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠


profile picture

Custom views pages


  • profile picture
  • Member

Posted 03 April 2015 - 11:15 AM

Hello everyone, I state that I do not program in php since college and I'm very rusty on the subject.

I recently discovered grocery because I was looking for a MFC framework that was quick to implement, and I must say that I am very well.
One of my biggest problems is not being able to easily implement the views to get the custom forms.
I have read that about the most popular suggestion is to wrap the output in a div and then edit it via javascript. For me that's not enough (and I don't like javascript too).
My idea is to create on the fly the pages of alternatives to the default view template that i need and utilize them by specifying their names it in the controller,

To do so I edited application/libraries/Gorcery_CRUD.php in this way:

line 4434. public function render($addLayout = null)
prev was:  public function render()
line 4482. $this->showAddForm($addLayout);
prev was:  $this->showAddForm();
line 1802. protected function showAddForm($layout = null)
prev was:  protected function showAddForm()
line 1819. if($layout == null) $this->_theme_view('add.php',$data); else $this->_theme_view($layout, $data);
prev was: _theme_view('add.php',$data);

in this way I can redirect the wiev form 'add.php' to 'whatever.php' (obviously in the theme_view dir) simply in this way:

$output = $crud->render('whatever.php');

Well... this is not so elegant, and btw I do not like to edit libraries.

I think it would be better just to override the metods that I've edited.

Sorry for the long post, it was just to share and to say hello!





  • profile picture
  • Member

Posted 24 June 2015 - 22:40 PM

I was really looking for a solution like this. I'm facing a situation where my add_action must redirect to a custom form that I created. I can't change the core of grocery crud where I work, so I'm going to override these methods for now, but does someone know how to acomplish this another way? Is this option ever going to be put inside grocery crud? Thanks!


PS.: A question: How could I reference a file that is at my application/views directory? Without the need to put it on the themes directory. Thank you!


  • profile picture
  • Member

Posted 24 June 2015 - 23:04 PM

Actually, I did some research and what I wanted to do is easily done using getState().

if ($crud->getState() == 'add') { // redirect here }

Thank you..