change default component in controller in joomla - joomla

I am creating a component for joomla.
I have a controller like this
class dropdownControllerdropdown extends JControllerForm
{
}
the above controller called by this class
JToolBarHelper::addNew('dropdown.add');
after the controller called that load the dropdown component.otherwise by default the above controller call this component and view and layout .
index.php?option=com_dropdown&view=dropdown&layout=edit
but my component name is "test" .how I tell to the controller to do not load the "dropdown" component and load the "test" component?

Related

laravel-livewire return view on button click

I have one button in livewire view
<x-jet-button wire:click.prevent="confirmProcess" class="bg-blue-500 hover:bg-blue-700">
Next
</x-jet-button>
and here in controller my method
public function confirmProcess()
{
return view('livewire.confirm');
}
I also have view in livewire folder with name confirm.blade.php
I want to load different view on button click but when I click on button nothing happens.
how can I load other view also I want to use data from same controller also on other view.
Thanks
You can't return view from your confirmProcess method. What you can do is redirect from confirmProcess method to a named route like:
return redirect()->route('confirm');
Then from this route you can call the component like:
Route::get('/confirm-process', \App\Http\Livewire\Confirm::class)->name('confirm');

Laravel : how to execute controller function on button in view?

I want to call controller function in view page.
Here is function code :
public function annulerSeanceConduite(Request $request,SeanceConduite $seanceConduite)
{
//
$seanceConduite->statut = "Annulée";
$seanceConduite->save();
$request->session()->flash('message', 'Seance Conduite est annulée!');
return redirect('seanceConduites');
}
And the route :
Route::get('annulerSeanceConduite', 'SeanceConduiteController#annulerSeanceConduite');
You can assign name to your Route when you define it and use that name to generate the correct URL in your view file
Route::get('/annulerSeance/{id}', 'SeanceConduiteController#annulerSeanceConduite')
->name('annulerSeance');
and in your view file you use it like this
Annuler
Instead of a button, you could use a normal "a", or bind the link the the specified route to an onclick event on the button.

Laravel disable controller action layout

Is there a way to disable layout for certain controller method?
Im using something like $this->layout = null ,yet it still render the layout
The view im rendering obviously have a layout associate with it, i just wonder is it possbile to disable the layout from within controller method, without need to modify the blade file itself
Here is the controller:
class PurchaserController extends \BaseController
{
public function index()
{
$this->layout = null;
return View::make('purchasers.index');
}
}
The view:
#extends('layouts.master')
#section('content')
Content
#stop
Im using Laravel 4
Just remove
#extends('layouts.master')
from your view. That will prevent the view from loading.
Also - if you are using the #extends - then you dont actually need $this->layout() in your controller at all
Edit:
" i just wonder is it possbile to disable the layout from within controller method, without need to modify the blade file itself"
The idea is you do it either entirely from the controller, or entirely from the blade file. Not both together.

CodeIgniter Dry Navigation

My boss told me make dry navigation dont use repetitive code, for navigation i am trying to extend CI_Controler and with construct load header nav, body, footer files.
My question is when i create new controller and when i try to load different view files, how to achive that???
my extended controler
class MY_Controller extends CI_Controller
{
public function __construct() {
parent::__construct();
$this->load->view('view_header');
$this->load->view('includes/nav_home');
$this->load->view('view_home');
$this->load->view('view_footer');
}
}
and later when i am creating new controler how to load diffrent view files
class Pages extends MY_Controller
{
public function __construct() {
$this->load->view('includes/nav_new_view');
$
}
}
You can create a template library yourself. For example :
function template($view_name,$view_data){
//below will return html string from view name
$data['content'] = $this->load->view($view_name,$view_data,true)
//load main template view and pass the html string to main template
$this->load->view('main_template',$data);
}
In main template, just echo $content
If I understand your question, you're trying to achieve a template situation. For this, the best way is to actually call your templates view files within a primary page view. What I mean is your controller function (not the constructor, an actual class function representing a page) should call a primary view such as
$this->load->view('page1', $this->data);
and within that file, you call
$this->load->view('nav', $this->data);
then your content and then
$this->load->view('footer', $this->data);
You would then repeat the process for page 2 where in your controller's page2 function, you would call
$this->load->view('page2', $this->data);
and your page2 view file is almost identical to page1 except you use your page 2 content in that area.
You could even use a single template view file and pass it a $content variable (which obviously changes per page) and call
$this->load->view('template', $this->data);

Passing parameter to same page with CodeIgniter

I have a controller that loads a page view. The page is actually a template of sorts; when a user clicks a button, content is loaded into a div based on the parameters passed through the button link. All button URLs go to the same page, it just passes a parameter. So for example, I have a page controller and a page_view file. When I click on the login button I want to go to the same page, but just pass action="login". If I clicked on "see stats", then I would want to pass action="stats".
Without Codeigniter I know I can just set the URLs on the buttons to "?action=stats" or "thisurl?action=stats", and within the page itself I have code that checks to see what the value of action is, and then generated content based on value.
How can I do this with the CodeIgniter framework?
You can call methods on a controller. So if you call a page like /your_controller/login, then it will call the login method in the controller and you can change the view to match that:
class Main extends CI_Controller {
function Main(){
parent::__construct();
// called when /main is accessed
// load your main view here
}
function login(){
// called when /main/login is accessed
// tweak view to match login view
}
}
More info here: http://codeigniter.com/user_guide/general/urls.html

Resources