1 to 2 of 2
I'm not sure how else to describe it, but here's what I'm trying to do:
When editing a part, list a small table of the related entries from the "conditions" table, with buttons that pop up a new window to Edit or Delete each condition. (I'll work on the js new window part later)
Here's what I've done so far:
- copied and renamed the 'listing.tpl' in "app/view/condition/" to _listing.tpl (so it'll be recognized as a partial, like the _form.tpl)
- edited _listing.tpl, removing a bunch of stuff BEFORE {?conditions} and removing the ending div tag.
- Added "var $models = 'condition, part, parts_vendors, vendor'; " inside the part_controller.php.
- Inside the function edit, inside the part_controller, I added $this->conditions = $this->Condition->find('all',array(
'conditions' => 'conditions.part_id = '.@$this->params['id'],
'order' => 'created_at DESC'));"
(to create the source for the _listing.tpl)
- Inside the "views\part_form.tpl" I added <p>
<label>_{Part Conditions}</label><br />
<?php echo $controller->renderPartial('../condition/listing')?>
</p>
This almost works, except for an error that I'm trying to trace down. The edit page loads great all the way till it gets to '$condition_helper', and then it throws an error like such Notice: Undefined variable: condition_helper in /home/sambaserve/web/apps/inventory/app/views/condition/compiled/_listing.tpl.php on line 44
Which causes it to fail on the remainder of that line as well.
Perhaps I'm doing this all wrong. I hope that in working this out by hand I can get a feel for how Akelos is setup. Can someone point me in the direction so I can get the $condition_helper 's working when called from a part edit view? Or perhaps a differn't way to do it? I'd love to see some tutorials on this exact subject. Hmm.. shouldn't there be something like this is a regular blog setup? hmm..
And it's solved! For anyone else who needs to move helpers to a global scale, try the following in your application_helper.php file.
class ApplicationController extends AkActionController {
var $app_helpers = 'my_global';
}
Where 'my_global' is the name of your controller.
I used this to make my application work:
class ApplicationController extends AkActionController {
var $app_helpers = 'condition';
}
And I had to modify show, edit, and destroy functions in condition_helper.php to look somewhat like this: return $this->_controller->url_helper->link_to($this->_controller->t('Edit'),
array('controller' => 'condition', 'action' => 'edit', 'id' => $record->getId()));
1 to 2 of 2