How do I add a tab to the Sale Order Admin Page? - magento

I want to add a custom tab to the order page in the admin of magento. Is there a way to do this with a simple override?

Assuming you know how to do a module, here are the steps you need to perform:
layout update: in your admin's xml layout file you want to "listening" to the admin's order view rendering handle and add your tab:
<layout>
<adminhtml_sales_order_view>
<reference name="sales_order_tabs">
<action method="addTab"><name>the_name_of_your_tab</name><block>the_block_alias_of_your_module/path_to_your_tab_file</block></action>
</reference>
</adminhtml_sales_order_view>
</layout>
the tab file: I generally try to respect Magento's folder structure, so this file would be in app/code/local-or-community/YourNamespace/YourModule/Block/Adminhtml/Order/View/Tab/File.php and will have at least:
<?php
class YourNamespace_YourModule_Block_Adminhtml_Order_View_Tab_File
extends Mage_Adminhtml_Block_Template
implements Mage_Adminhtml_Block_Widget_Tab_Interface
{
protected $_chat = null;
protected function _construct()
{
parent::_construct();
$this->setTemplate('yourmodule/order/view/tab/file.phtml');
}
public function getTabLabel() {
return $this->__('Tab label');
}
public function getTabTitle() {
return $this->__('Tab title');
}
public function canShowTab() {
return true;
}
public function isHidden() {
return false;
}
public function getOrder(){
return Mage::registry('current_order');
}
The .phtml file, which has to respect the path you specified in the block's __construct(), and should hace something like:
<div class="entry-edit">
<div class="entry-edit-head">
<h4><?php echo $this->__('a title'); ?></h4>
</div>
<div class="fieldset fieldset-wide">
the content you want to show
</div>
</div>
Hope That Helps

Related

Livewire, modal is not shown, why?

muestramodal.blade.ph
<x-button.link wire:click="edit">Edit</x-button.link>
<x-modal.dialog wire:model="edit">
<x-slot name="title">Edit transaction</x-slot>
<x-slot name="content">Hola</x-slot>
<x-slot name="footer">
</x-slot>
</x-modal.dialog>
muestramodal.php
<?php
namespace App\Http\Livewire;
use Livewire\Component;
class Muestramodal extends Component
{
public $showEditModal = false;
public function edit()
{
$this->showEditModal = true;
}
public function render()
{
return view('livewire.muestramodal');
}
}
Why is not shown modal , with click event button???
Several hours trying to solve this problem.....
Please , can anyone help me? Thanks
need to update your muestramodal.php and extends LivewireUI\Modal\ModalComponent;
<?php
namespace App\Http\Livewire;
LivewireUI\Modal\ModalComponent;
class Muestramodal extends ModalComponent
{
public $showEditModal = false;
public function edit()
{
$this->showEditModal = true;
}
public function render()
{
return view('livewire.muestramodal');
}
}

How do I get Joomla module title in custom fields?

I am creating a custom field in Joomla. I have this code:
class JFormFieldEmbed extends JFormField {
protected $type = 'Embed';
public function getInput() {
$out='';
$out.='<pre>'.print_r($this->form,true).'</pre>';
return $out;
}
}
I see in the output $form->data that contains the title but is a protected object.
How do I get Joomla module title in custom fields?
UPDATE:
By now my solution with JavaScript:
class JFormFieldEmbed extends JFormField {
protected $type = 'Embed';
public function getInput() {
$script1=htmlentities('<script type="text/javascript" src="'.JURI::root().'modules/mod_mydodule/js/script.js" data-title="');
$script2=htmlentities('"></script>');
return<<<EOD
<div id="embedmymodule"></div>
<script type="text/javascript">
jQuery(function($){
$("#embedmymodule").html('$script1'+encodeURIComponent( $('[name=\"jform[title]\"]').val() )+'$script2');
});
</script>
EOD;
}
}
This code will output the module title:
$module->title
Found the answer in the source files of Joomla:
echo $this->form->getValue('title');

Add template to widgets un magento

I am integrate custom template to widget but its doesn't show the template data. below is my code
community/Sample/Productslider/etc/widget.xml
<widgets>
<productslider_bestseller type="productslider/bestseller" translate="product slider option" module="productslider">
<name>Best Seller Product</name>
<description type="desc">Enable the Best Seller Product Widget</description>
<parameters>
<template>
<required>1</required>
<visible>1</visible>
<label>Template</label>
<type>select</type>
<values>
<best-seller translate="label">
<value>productslider/best-seller.phtml</value>
<label>Best Seller</label>
</best-seller>
</values>
</template>
</parameters>
</productslider_bestseller>
</widgets>
community/Sample/Productslider/Block/Bestseller.php
class Sample_Productslider_Block_Bestseller extends Mage_Core_Block_Abstract implements Mage_Widget_Block_Interface
{
protected function _construct()
{
parent::_construct();
}
protected function _toHtml()
{
$pageTitle = '';
$headBlock = $this->getLayout()->getBlock('head');
if ($headBlock) {
$pageTitle = $headBlock->getTitle();
}
$html = "test";
$this->assign('best-seller', $html);
return parent::_toHtml();
}
}
fronted/base/default/template/productslider/best-seller.phtml
echo $html;
It show blank page in front when i include widget in cms page.
Any one can help me to find out the issue in my code.
Thanks
To me your issue consists in extending Mage_Core_Block_Abstract in which _toHtml method return a void string.
Just set your template in your constructor and extends Mage_Core_Block_Template instead of Mage_Core_Block_Abstract
You can assign a template to a block via the constructor (example taken from core file : /app/code/core/Mage/Catalog/Block/Layer/State.php:43)
public function __construct()
{
parent::__construct();
$this->setTemplate('catalog/layer/state.phtml');
}
So you would have to do something like this in your __contruct
$this->setTemplate('productslider/best-seller.phtml');
But what you seems to have trouble with is passing data to this template ?
Then, make is as you would in any other template :
In your block :
public function getSomeExtraHtml(){
return 'test';
}
In the template :
<?php echo $this->getSomeExtraHtml() ?>
You'll have to set the template in your Block Class
protected function _toHtml()
{
$this->setTemplate('my_module/widget.phtml');
return parent::_toHtml();
}
Create a folder under
app/design/frontend/your_theme/default/my_module and add your html file

How to create login / registerform template with auth_tank/codeigniter?

Struggling to figure out how to achieve this. I want a login/registerform on same page when using tank_auth in CodeIgniter.
I was thinking of having something like this in my members controller (which extends My_Controller which extends Auth).
class Members extends My_Controller (
public function login()
{
//Already loggedin, do nothing
if ($this->tank_auth->is_logged_in()) {
return;
}
$this->view_data['login_by_username'] = true;
$this->view_data['login_by_email'] = false;
$this->view_data['show_captcha'] = false;
$this->view_data['login_form'] = $this->load->view('auth/login_form', $this->view_data, TRUE);
$this->view_data['register_form'] = $this->load->view('auth/register_form', $this->view_data, TRUE);
$this->v('members/login_register'); //In this view $login_form and $register_form is rendered
}
}
When I go to that page (localhost/members/login) the members/login-view is shown as expected, but in the action of the form for loginform it says:
http://localhost/members/login
Therefore when I click "Login-button" then it just calls members/login and that's not what I want. I want the action to be auth/login, but I still want to use my own template.
I hope you guys understand what I mean.... Please tell me if I'm doing anything wrong/thinking of this incorrectly.
UPATE:
In the actual template (members/login_register) it looks like this:
<div class="column">
<?php echo $login_form;?>
</div>
<div class="column>
<?php echo $register_form;?>
</div>
Maybe what I want to achieve is not possible?
Master View
You should use a Master view as a wrapper for your content.
That way you can easily pass in partial views(although not required)
However it will keep things neat. It also allows for easier control over
Admin/User Dashboards and your frontend.
Main Controller
class MY_Controller extends CI_Controller
{
public $template;
public function __construct()
{
$this->template = "master/template"; //views/master/template
}
}
To change it for an admin template(as an example of flexibility) you simply need to change it
the variable in the __constructor
class Admin_Controller extends MY_Controller
{
public function __construct()
{
$this->template = "master/admin/template"; //views/master/admin/template
}
}
Partial View(s)
Partial views can be used directly in other views.
You don't need a controller to call them.
These views are just stored in the buffer when they are
loaded by the loader class $this->load->view('', '', true)
A common approach is to create a folder inside /views called "partials".
This is where you would keep all you re-usable views(such as forms/widgets).
The Views(/views/partials/login_form)
<div>
<?php echo form_open('members/login', array('id'=>'login-form'))
</div>
The Views(/views/partials/signup_form)
<div>
<?php echo form_open('members/signup', array('id'=>'signup-form'))
</div>
The Views(members/index)
You can then combine the views
<div class="signup-form">
<?php echo $this->load->view('partials/signup_form')
</div>
<div class="login-form">
<?php echo $this->load->view('partials/login_form')
</div>
Login / Signup
In your members class you can create one method to show
the register/login form and then create methods to handle each of them individually.
class Members extends MY_Controller
{
public function index()
{
return $this->load->view('members/login_register');
}
public function login()
{
if(!$this->form_validation->run()){
return $this->index();
}
// form validation passed Ask Tank Auth
// to log the user in
$tank->auth->login();
}
public function signup()
{
if(!$this->form_validation->run()){
return $this->index();
}
// form validation passed Ask Tank Auth
// to register
$tank->auth->register();
}
}

How to add custom tab to cms pages tab panel in custom module magento

How can i add extra tab for cms tabs menu on edit page of cms block using my custom module.Can anyone help.
Thanks
You can use layout and add your own block to the tab:
<?xml version="1.0"?>
<layout version="0.0.1">
<adminhtml_cms_page_edit>
<reference name="cms_page_edit_tabs">
<block type="module/cms_page_edit_tab_tags" name="cms_page_edit_tab_tags" after="cms_page_edit_tab_meta"/>
<action method="addTab"><name>tags_section</name><block>cms_page_edit_tab_tags</block></action>
</reference>
</adminhtml_cms_page_edit>
</layout>
and block implementation
class My_Module_Block_Cms_Page_Edit_Tab_Tags
extends Mage_Adminhtml_Block_Widget_Form
implements Mage_Adminhtml_Block_Widget_Tab_Interface
{
protected function _prepareForm()
{
$form = new Varien_Data_Form();
$this->setForm($form);
// your tab code here
return parent::_prepareForm();
}
public function getTabLabel()
{
return Mage::helper('cms')->__('Cms Pages Products');
}
public function getTabTitle()
{
return Mage::helper('cms')->__('Cms Pages Products');
}
public function canShowTab()
{
return true;
}
public function isHidden()
{
return false;
}
}
Look at app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/* and app/design/adminhtml/default/default/layout/cms.xml for implementation

Resources