Thanks every one, I have looked at the responses and have made progress, I have it working for the edit view but not the details view.
For thew edit view file custom/modules/CoMO_Orders/views/view.edit.php I have thiws code what works well.
<?php
require_once ‘include/MVC/View/views/view.edit.php’;
class CoMO_OrdersViewEdit extends ViewEdit
{
// function runs before view is disaplyed.
public function preDisplay()
{
//echo $_POST['record'];
//get the record ID file
$bean = BeanFactory::getBean('CoMO_Orders', $_POST['record']);
//chec the order type, if it is not a plot (or related order), load quickcreate view.
if ($bean->order_type == "Repair" || $bean->order_type == "Other" || $bean->order_type == "Stock") {
//load smalledit view.
header('Location: /index.php?module=CoMO_Orders&action=SmallEdit&record=' . $bean->id);
exit;
} else {
//contiue to load this view.
$this->ev = new EditView();
$this->ev->ss = &$this->ss;
$this->ev->view = "EditView";
$metadataFile = "modules/CoMO_Orders/metadata/editviewdefs.php";
$this->ev->setup($this->module, $this->bean, $metadataFile, 'include/EditView/EditView.tpl', true, 'editviewdefs');
}
}
}
For the Details view, I have tried to copy it so i have this /var/www/html/custom/modules/CoMO_Orders/views/view.detail.php
<?php
require_once ‘include/MVC/View/views/view.detail.php’;
class CoMO_OrdersViewDetail extends ViewDetail
{
// function runs before view is disaplyed.
public function preDisplay()
{
$bean = BeanFactory::getBean('CoMO_Orders', $_GET['record']);
//chec the order type, if it is not a plot (or related order), load quickcreate view.
if ($bean->order_type == "Repair" || $bean->order_type == "Other" || $bean->order_type == "Stock") {
header('Location: /index.php?module=CoMO_Orders&action=SmallDetail&record=' . $bean->id);
exit;
} else {
$metadataFile = "custom/modules/CoMO_Orders/metadata/detailviewdefs.php";
$this->dv = new DetailView2();
$this->dv->ss = &$this->ss;
$this->dv->setup($this->module, $this->bean, $metadataFile, get_custom_file_if_exists('include/DetailView/DetailView.tpl'));
}
}
}
If the record is no a Repair, Other or Stock. It works fine. If it is then it open up the error window and displays the record in there, Please see the screen shot attached.
IS there a better way to load a different view?