Questions tagged [controller]

A controller is responsible for executing a sequence of instructions in response to some stimulus (maybe a command, action, or event). This tag is appropriate for questions pertaining to the controller of a Model-View-Controller pattern.

Filter by
Sorted by
Tagged with
1
vote
1answer
30 views

Where does JControllerLegacy::redirect() redirect to?

I'm trying to understand the tutorial at https://docs.joomla.org/J3.x:Developing_an_MVC_Component/Adding_a_view_to_the_site_part, but I don't understand the last line of code ($controller->redirect(...
0
votes
1answer
61 views

Trigger controller method from another component

I'm working on SOAP method to update some values in some component. I need to trigger the save() method from a controller of a particular component, but I'm unable to get an instance of the controller ...
1
vote
1answer
54 views

Error JLIB_APPLICATION_ERROR_INVALID_CONTROLLER from CLI on Joomla 3.7

I have an issue with a cli php script that I'm trying to execute. I want to add an article with custom fields. The part where I add articles is working well, but when I add the code to load the ...
1
vote
2answers
36 views

Deleting rows in two different tables

I'm trying to make function (task) and deleting rows in two tables. But I don't get this sql query working, I only got this error: 1064 - An error has occurred. You have an error in your SQL syntax; ...
0
votes
1answer
30 views

How to extend class on my component class in controller.php

I have created a Basic Joomla Component with Component Creator in order to prepare every single files in less the 1 minute :D (I'm lazy, i know.) I have one view default and one for form edit. I ...
0
votes
1answer
33 views

Ajax Request returning the whole page not a specifc value

I am trying to make an AJAX Request to my function in my controller and it works, however, it returns me the whole page which i don't want. I have tried encoding it with json but no success i also ...
1
vote
1answer
69 views

Why does the FormController instantiate models with the ignore_request flag set to true?

The Joomla\CMS\MVC\Controller\FormController::getModel method has a default argument for the config argument that sets the ignore_request parameter to true. This in turn means that models will not ...
1
vote
1answer
37 views

Add custom code to the controller from com_weblinks

I want to add analytics tracking code before the component com_weblinks jumps to an external site with task=weblink.go. The problem is the jump is in the controller.php file. An override for this ...
2
votes
2answers
40 views

How to remember User State settings when returnng to a Site View?

I have a fairly straightforward front end List display with pagination and headings that can sort columns and navigate to a different page number and everything works as expected. The URL for the page ...
2
votes
1answer
77 views

Sharing a model between two views in a component

I have one model I'd like to use for two different views. This is the only model these two views will require. I'm subclassing Joomla\CMS\MVC\Controller\BaseController and I'd like to use its display ...
2
votes
1answer
60 views

Why are methods randomly placed in models as well as controllers in Joomla

I am quite new in Joomla. I have now understood the components, modules, templates thing and can also build modules and simple components. But the one thing that has always confused me in Joomla is ...
0
votes
1answer
81 views

Is it possible to check if a method or function exists in the component controller?

I have a custom component that will be using various AJAX calls, based on outside settings. How can I load "this" controller from the View or Model to determine if a method/function exists, i.e. PHP ...
1
vote
1answer
54 views

How can I have a dynamic $default_view?

Something along the lines of: JLoader::Register('MyComHelperConfig', JPATH_COMPONENT_ADMINISTRATOR . '/helpers/config.php'); class MyComController extends JControllerLegacy { protected $...
3
votes
2answers
3k views

Pass results (array) from controller into view and show it

I'm experimenting with creating my own Joomla component. The component searches records in database tables, but I have a problem with how to show them. I have a search form that sends the search ...
1
vote
1answer
687 views

What controller does front end form data post to using a component

I have been using Joomla for the last couple weeks and it seems straightforward so far and I understand the code in examples. I've successfully created a custom module that displays on the front end. ...
1
vote
1answer
221 views

Pass argument to controller methods

Is it possible to pass arguments to controller action methods, like public function someAction($myArgument) { ... } Or is using JInput the only way? Edit: Using a URL like option=com_mycomponent&...
1
vote
1answer
565 views

Override View path in the Controller is only partially working

In my main controller, I'm successfully incorporating a custom path for the Model, but seem to be missing something for the custom path to the View. The component path is: \components \...
1
vote
1answer
1k views

Form-Validation in Frontend

I'm trying to get my component ready for frontend-action. There are some forms that are filled by the user - but of course I have some fields that need specific values (int, float, ...) and some ...
0
votes
0answers
873 views

Model/Controller: get id of current item and use it in controller

I got a view in my component's frontend, which catches data from model using the ID of the element: protected function populateState($ordering = null, $direction = null) { $app = ...
4
votes
2answers
689 views

Custom component: Export items to CSV -> Changing searchbar causes a new download

I would like to export all selected items from the items-view of my component. To do so I modified my view and inserted a new button to the JToolBarHelper::custom('items.exportcsv', 'download', '', ...
2
votes
2answers
557 views

Call Controller's Publish-Method from CLI or Helper

I would like to call the publishing-method I defined in my item's controller from a CLI-script or a helper (which is included in the CLI). The best case would be to call it like this: $...
6
votes
1answer
7k views

Best way to include helper class in sub-controller : require_once or JLoader

I have created a helper file test.php as following: administrator/components/com_compname/helpers/test.php class TestHelper{ //class methods } In controllers/subcontrollername.php We can use ...
0
votes
1answer
233 views

Friendly links to call a controller task

I developed an ecommerce component and I have the following problem that I hope you could help me. The component has a locations manager where we can enlist cities such as: Madrid, London, Paris, ...
2
votes
1answer
29 views

Create Dialog on publishing methods

I would like to create a little dialog on publishing-events on an item of my self-developed component. For example: Item gets published - the item's controller is called and rund method publish with $...
7
votes
3answers
14k views

How to get menu parameters and itemid in component controller

In my custom component controller I have function save(). At the end it displays message and redirects to url $this->setMessage(JText::_('SOME_TEXT')); $this->setRedirect(JRoute::_('index.php?...
1
vote
1answer
42 views

State set to 0 after parent::publish

I'm extending my controller's publishing method for a task called "setup". This is the extended method: /** * publish function. * * @access public * @return void */ public function publish() { ...
3
votes
3answers
2k views

Insert query not working within a loop

I am trying to insert records in a loop. But unable to do so. Following is my code: historical.raw.php : created a task in controller of format raw public function historical() { $db = JFactory::...
1
vote
1answer
725 views

Controller error: Invalid controller: name='dasdada'

I am trying to send information from a to a DB. I am using Jfactory. This is the HTML: <textarea name="task" class="form-control" id="task"></textarea> Variable: $_POST['task'] This ...
1
vote
1answer
890 views

Joomla-Development: Set default view

I would like to set up a default view. If my component gets called by using administrator/index.php?option=com_bestia&view= I'm getting the error: 404 View not found [Name, Typ, Präfix]: bestia,...
3
votes
2answers
629 views

Call controller's publish-function from “outside”

I modified the publish-function of my sub-controller as follows /** * publish function. * * @access public * @return void */ public function publish() { $...
5
votes
1answer
498 views

Extend publishing in controller?

I would like to extend the (un)publish-function in a sub controller. I thought it would be enough to write something like that to my sub controller items.php: public function unpublish() { ...
1
vote
3answers
403 views

Joomla 3.4.3 get fatal error while opening plugins

While trying to open any plugin from Joomla administration, a blank page with this error message displays: Fatal error: Call to a member function getTable() on a non-object in .../libraries/legacy/...
4
votes
2answers
2k views

How to remove component name from URL?

I am making a custom component and I dont want the name of the component on the URL when component loads. The URL is coming like this : http://example.com/component/componentName/view=viewName But ...
3
votes
3answers
923 views

Load controller dynamically just like model

As we can load third party component model like this: Loader::import('joomla.application.component.model'); JLoader::import('modelname', JPATH_ROOT.'/components/com_componentname/models'); $model = ...
4
votes
2answers
3k views

How to override a component's controller

I want to override a controller inside a component ie; File path : components/com_test/controllers/test.php how can I override test.php ?