The buttons are created in Mage_Adminhtml_Block_Sales_Order_View::__construct with $this->addButton function calls.
As for the events you could use one of them but I can't recall from the top of my head which one (if any) would be apropriate to call.
To list all the events that get triggered you could add logging into Mage::dispatchEvent function with Mage::log( $name );
With that name you could declare a listener in config.xml (under config/global/events tag path):
<name_that_was_printed_by_the_above_function>
<observers>
<YourModuleNamespace_YourModuleName>
<class>moduleName/observer</class>
<method>functionName</method>
<type>model</type>
</YourModuleNamespace_YourModuleName>
</observers>
</name_that_was_printed_by_the_above_function>
and then create a module class Observer.php
class Namespace_ModuleName_Model_Observer
{
public function functionName( Varien_Event_Observer $observer )
{
$block = $observer->getEvent()->getData( 'data_object' ); // this line may vary
$block->addButton( ...stuff here... // take for reference the answer from the question you linked to
return $this;
}
}
But like I said it's possible that none of the observers will suit your needs and you'll have to find another more intrusive solution...
Edit
You'll probbably have to use core_block_abstract_to_html_before and have an if statement to check if it's the right block... The downside is that it gives a call overhead and an if statement overhead for every block so I'm not certain if it's the best solution but it's certainly the least intrusive so I'd probably use it (the 'data_object' should be changed to 'block' in case of this event - event is triggered in Mage_Core_Block_Abstract::toHtml the dispatchEvent line).
Edit
After your question update I've tested your module and like I have warned in the comments the problem is the name of your module - lower case.
app/etc/modules/CaitlinHavener_PrintOrder.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<CaitlinHavener_PrintOrder>
<active>true</active>
<codePool>local</codePool>
</CaitlinHavener_PrintOrder>
</modules>
</config>
app/code/local/CaitlinHavener/PrintOrder/etc/config.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<CaitlinHavener_PrintOrder>
<version>0.1.0</version>
</CaitlinHavener_PrintOrder>
</modules>
<global>
<events>
<core_block_abstract_to_html_before>
<observers>
<CaitlinHavener_PrintOrder>
<class>CaitlinHavener_PrintOrder_Model_Observer</class>
<method>orderPageButton</method>
<type>model</type>
</CaitlinHavener_PrintOrder>
</observers>
</core_block_abstract_to_html_before>
</events>
</global>
</config>
local/CaitlinHavener/PrintOrder/Model/Observer.php
<?php
// Order View Page button
class CaitlinHavener_PrintOrder_Model_Observer
{
public function orderPageButton( Varien_Event_Observer $observer )
{
$block = $observer->getEvent()->getData( 'block' );
if(get_class($block) =='Mage_Adminhtml_Block_Sales_Order_View'
&& $block->getRequest()->getControllerName() == 'sales_order')
{
$block->addButton('test_print', array(
'label' => 'Test',
'onclick' => 'setLocation(\'' . $block->getUrl('html/sales_order/print') . '\')',
'class' => 'go'
));
}
}
}
?>
Be carefull that you correctly name your files (watch for upper case characters) and copy the code and it should work.
I used a way easier approach to the color.
first I override the core grid on my local folder:
app/code/local/Mage/Adminhtml/Block/Sales/Order/Grid.php
Then I added my custom column and added the renderer attribute to it.
$this->addColumn('fee_amount', array(
'header' => Mage::helper('sales')->__('Amount to be Paid Later'),
'index' => 'fee_amount',
'filter_index'=>'fee_amount',
'type' => 'currency',
'currency' => 'base_currency_code',
'width' => '80px',
'renderer' => 'Mage_Adminhtml_Block_Sales_Order_Renderer_Red',
));
Then create Red.php under
app/code/local/Mage/Adminhtml/Block/Sales/Order/Renderer/Red.php
On red.php i added the following:
class Mage_Adminhtml_Block_Sales_Order_Renderer_Red extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
{
public function render(Varien_Object $row)
{
$value = $row->getData($this->getColumn()->getIndex());
return '<div style="color:#FFF;font-weight:bold;background:#F55804;border-radius:8px;width: 40%;margin-left: 40px;">$'.number_format( $value , 2).'</div>';
}
}
Best Answer
I solved it a little bit after I posted. The solution for me was the following: