Custom View depending field value

I am using your function as you typed it. I have it working on my system now.

I assume that you have developer mode active, meaning no caching?

I have added the flowing lines to clear the theme cache for this module when it loads. and that seems to have fixed it.

    $repair = new RepairAndClear();
    $repair->repairAndClearAll(array('clearThemeCache'), array(translate('CoMO_Orders')), true, false);

So the whole class looks like this:

class CoMO_OrdersViewDetail extends ViewDetail{
public function getMetaDataFile(){

    if ($this->bean->order_type == "Repair" || $this->bean->order_type == "Other" || $this->bean->order_type == "Stock") {

        $oldType = $this->type;

        $this->type = $oldType . 'ros';

    }

    $metadataFile = parent::getMetaDataFile();

    if ($this->bean->order_type == "Repair" || $this->bean->order_type == "Other" || $this->bean->order_type == "Stock") {

        $this->type = $oldType;

    }

    return $metadataFile;

}

public function preDisplay(){

    // find out what meta file is needed

    $metadataFile = CoMO_OrdersViewDetail::getMetaDataFile();

    // Rebuild theme for this moudle to clear the cache, making sure the correct view loads.

    $repair = new RepairAndClear();

    $repair->repairAndClearAll(array('clearThemeCache'), array(translate('CoMO_Orders')), true, false);

    //load view.

    $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'));

}

}

Thanks for you help. I am interested if this is the correct way, as it seems silly to have to clear the cache each load, but for out needs, i doubt it will be too much of an issue.