how to set payment info.phtml for adminhtml - magento

how to set payment info.phtml for adminhtml ...
like set for the frontend...something like this
class Ks_Gippayment_Block_Info extends Mage_Payment_Block_Info
{
protected function _construct()
{
parent::_construct();
$this->setTemplate('ks/info.phtml');
}
thanks :D

This code will also do the job for adminhtml. Just make sure the following template exists:
app/design/adminhtml/base/default/template/ks/info.phtml

Related

Dynamically hide Laravel barryvdh debugbar

I could not able to hide Laravel Debugbar dynamically, i.e on the run time. I have tried the following from parent Controller class constructor:
<?php
namespace App\Http\Controllers;
class Controller extends BaseController {
use AuthorizesRequests,
DispatchesJobs,
ValidatesRequests;
public $foo = 'null';
public function __construct() {
\Debugbar::disable();
// and also
config(['debugbar.enabled' => false]);
....
All of the above tries failed. I'd like to mention that controller is the parent controller of all other controllers' classes.
The only working way is not dynamic way, where I have to change configuration manually. I don't know why the override configurations doesn work as the documentation states?
Without seeing all you code, yours should work. Here is how I configure mine to work in a local environment and disable it with specific requests.
AppServiceProvider
use Barryvdh\Debugbar\ServiceProvider as DebugbarServiceProvider;
...
public function register()
{
if ($this->app->environment('local')) {
$this->app->register(DebugbarServiceProvider::class);
}
}
Where I would like to disable I put.
use Barryvdh\Debugbar\Facade as Debugbar;
...
if (App::environment('local')) {
Debugbar::disable();
}
Update per comment
Why do you put something in your routes file like this.
use Barryvdh\Debugbar\Facade as Debugbar;
...
Route::group(array('domain' => 'admin.example.com'), function()
{
Debugbar::disable();
});

how to add grid under a tab in magento custom admin module?

I want to create a grid in my custom module under a tab section as like would show up under customer ->wish list tab.
Assuming that your using Method 3 # http://www.nextbits.eu/blog/how-to-add-tab-in-customer-information-in-magento-admin/
class Namespace_ModuleName_Block_Adminhtml_Customer_Tab
extends Mage_Adminhtml_Block_Template
implements Mage_Adminhtml_Block_Widget_Tab_Interface {
/**
* Set the template for the block
*
*/
public function _construct()
{
parent::_construct();
$this->setTemplate('modulename/customer/tab.phtml');
}
in modulename/customer/tab.phtml
<?php
echo $this->getLayout()
->createBlock('modulename/adminhtml_modulename_grid')
->toHtml();
?>

Laravel 4: Reference controller object inside filter

I have a controller in Laravel 4, with a custom variable declared within it.
class SampleController extends BaseController{
public $customVariable;
}
Two questions: Is there any way I can call within a route filter:
The controller object where the filter is running at.
The custom variable from that specific controller ($customVariable).
Thanks in advance!
as per this post:
http://forums.laravel.io/viewtopic.php?pid=47380#p47380
You can only pass parameters to filters as strings.
//routes.php
Route::get('/', ['before' => 'auth.level:1', function()
{
return View::make('hello');
}]);
and
//filters.php
Route::filter('auth.level', function($level)
{
//$level is 1
});
In controllers, it would look more like this
public function __construct(){
$this->filter('before', 'someFilter:param1,param2');
}
EDIT:
Should this not suffice to your needs, you can allways define the filter inside the controller's constructor. If you need access to the current controller ($this) and it's custom fields and you have many different classes you want to have that in, you can put the filter in BaseController's constructor and extend it in all classes you need.
class SomeFancyController extends BaseController {
protected $customVariable
/**
* Instantiate a new SomeFancyController instance.
*/
public function __construct()
{
$ctrl = $this;
$this->beforeFilter(function() use ($ctrl)
{
//
// do something with $ctrl
// do something with $ctrl->customVariable;
});
}
}
EDIT 2 :
As per your new question I realised the above example had a small error - as I forgot the closure has local scope. So it's correct now I guess.
If you declare it as static in your controller, you can call it statically from outside the controller
Controller:
class SampleController extends BaseController
{
public static $customVariable = 'test';
}
Outside your controller
echo SampleController::$customVariable
use:
public function __construct()
{
$this->beforeFilter('auth', ['controller' => $this]);
}

My custom block not showing header buttons on admin side in magento

I am calling my block from controller but it doesn't display header buttons.I call my controller function with button click and create block using (
$this->loadLayout();
$this->_addContent($this->getLayout()->createBlock('mymodule/adminhtml_mymodule_edit_tab_addanswer'));
$this->renderLayout();.
While on addanswer page i simply use the class
Mymodule_Block_Adminhtml_module_Edit_Tab_Addanswer extends Mage_Adminhtml_Block_Widget_Form
{
protected function _prepareForm()
{
// code
}
}
It display data like the attach image
I want to add save or add like buttons but don't know from where i can do that.I added buttons from block or from edit.php but i don't know how i can add buttons from controller or in form direct.Is it possible ? Thanks in advance
You maybe missing
class CompanyName_Mymodule_Block_Adminhtml_Addanswer_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
{
public function __construct()
{
parent::__construct();
$this->_objectId = 'id';
$this->_blockGroup = 'addanswer';
$this->_controller = 'adminhtml_addanswer';
$this->_updateButton('save', 'label', Mage::helper('addanswer')->__('Save'));
$this->_updateButton('delete', 'label', Mage::helper('addanswer')->__('Delete'));
}
.....
Take a look # Custom Module with Custom Database Table

base controller and apply it to all existing controller

I need to create codeigniter base controller to check allowed ip address in database by mobel function if the ip is exists then user should go to home page but if the ip address is not exists and show 404 page in codeigniter, i can't find core folder in application folder
First, you need to extend a core class, call it MY_Controller.php
Save that file in: application/core/MY_Controller.php
class MY_Controller extends CI_Controller {
function __construct()
{
parent::__construct();
$this->load->model('ip_table_model');
$this->load->library('input');
// assuming there's a function called "check_ip($ip_address)" in ip_table_model
if (!$this->ip_table_model->check_ip($this->input->ip_address()) {
redirect('error_404');
}
}
}
Now, we're assuming you have a model called ip_table_model which connects to database with list of IP addresses, and there's a function called check_ip which will validate whether user has access or not. This is relatively simple, and I won't show any examples on this.
The redirect('error_404'); page does not yet exist, you need to create a controller which shows your 404 page.
Now, for any other controllers in your project, instead of extends CI_Controller, make them extend MY_Controller instead.
Here's an example:
class Welcome extends MY_Controller {
function __construct()
{
parent::__construct();
}
function index()
{
$this->load->view('welcome_message');
}
}
Explanation: We're extending CI_Controller to create our own core controller, called MY_Controller. Inside, we're checking if user has access or not through the constructor, which will be called in every other controller in the project.
References:
http://codeigniter.com/user_guide/general/core_classes.html
http://codeigniter.com/user_guide/libraries/input.html
Answer is here (section Extending Core Class).
1.7.2 has a different structure to 2.0.*, therefore there is no core folder in application
In Core Create a new Class .
Name MY_Controller.php
class MY_Controller extends CI_Controller {
// Write your functions here which you wanna use throughout the website
public function abc (){
echo "Helllo";
}
}
class Welcome extends MY_Controller {
function __construct()
{
parent::__construct();
}
function your_custom_fuctions()
{
$this->abc(); //echo Hello...
//Anything you want to do
}
}
function admin_view($view_name = "", $header_info = NULL, $sidebar_info=NULL,$page_info = NULL, $footer_info = NULL, $data_info = ""){
$this->load->view('Admin/includes/header', $header_info);
$this->load->view('Admin/includes/Left_sidebar', $sidebar_info);
$this->load->view($view_name, $page_info);
$this->load->view('common/footer', $footer_info);
}

Resources