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
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 ...
1
vote
1answer
59 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 ...
0
votes
1answer
17 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 ...
4
votes
2answers
674 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', '', ...
1
vote
1answer
858 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,...
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
37 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 ...
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 ...
2
votes
1answer
63 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
58 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
75 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 ...
2
votes
2answers
508 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: $...
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 ...
1
vote
1answer
53 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 $...
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 ...
1
vote
1answer
656 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
3answers
399 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/...
1
vote
1answer
213 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&...
7
votes
3answers
13k 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
545 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 \...
0
votes
0answers
843 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 = ...
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
230 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, ...
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 ?
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 $...
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
705 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 ...
3
votes
2answers
594 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
491 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() { ...
3
votes
3answers
902 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 = ...