As of May 31, 2023, we have updated our Code of Conduct.
10 votes
Accepted

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

Actually JLoader::register('TestHelper','/path/to/test.php'); dosen't load file, it just registers it to be able to autoload file if class is instantiated. Do require it instantly, you want to use: ...
Rene Korss's user avatar
  • 3,208
4 votes
Accepted

Extend publishing in controller?

Take a look at JControllerAdmin what is used to extend your controller. In __construct function on line 62 unpublish is set to use publish function. So there is no function like unpublish. And in ...
Rene Korss's user avatar
  • 3,208
3 votes
Accepted

How can I have a dynamic $default_view?

You can't set a class property to a dynamic value, such as a method call, during declaration like you're attempting. See http://php.net/manual/en/language.oop5.properties.php You would need to set it ...
Drew G's user avatar
  • 890
3 votes

How to get menu parameters and itemid in component controller

Use the following: $menu =& JSite::getMenu(); $activeMenu = $menu->getActive(); $Itemid = $activeMenu->id; or $menu =& JSite::getMenu(); $activeMenu = $menu-&...
Terry Carter's user avatar
  • 1,777
3 votes
Accepted

State set to 0 after parent::publish

You are calling parent::publish(). This method has an array which maps tasks to states (line 190): $data = array('publish' => 1, 'unpublish' => 0, 'archive' => 2, 'trash' => -2, 'report' =...
fruppel's user avatar
  • 3,723
3 votes

Joomla-Development: Set default view

I think your view files are missing or view class is named incorrectly (correct is [Prefix]View[Viewname]). If I change the name of administrator/components/com_banners/views/ to /viewx/ I get the ...
iamrobert's user avatar
  • 505
3 votes
Accepted

Load controller dynamically just like model

jimport('joomla.application.component.controller'); JLoader::import('controllername', JPATH_ROOT . '/components/com_componentname/controllers'); $controller = JControllerLegacy::getInstance('...
Purple Penguin's user avatar
3 votes

Joomla 4 Views will not load on some Hosts

HtmlView.php is case-sensitive. Also, all other files within the src folder for namespacing are case-sensitive. That is what was causing all the problems.
Brent Cordis's user avatar
2 votes

How to remove component name from URL?

You can use .htaccess In joomla with apache rewrite feature. Rename the file htaccess.txt to .htaccess In root joomla folder; Enable Apache rewrite In global configuration In joomla admin area.
Max's user avatar
  • 991
2 votes

Insert query not working within a loop

This can be done by using ->insert() and ->values(), with the $values being an array of the strings with the columns to insert. $db = JFactory::getDbo(); $query = $db->getQuery(true); $columns = ...
Joomler's user avatar
  • 1,791
2 votes

How to get menu parameters and itemid in component controller

After some testing, I was able to replicate the issue: **A form redirects to a view without a menu item or redirects to itself relatively to a url like this one: component/mycomponent/myview (It ...
Dennis Heiden's user avatar
2 votes
Accepted

Pass argument to controller methods

No, there isn't a way to pass arguments into methods. Specifically, this has to do with how JControllerLegacy::execute() routes the request. So you're left with using the request or session to fetch ...
Michael's user avatar
  • 1,620
2 votes

Call Controller's Publish-Method from CLI or Helper

Here is a CLI script I made that allows you to call controllers just as you would via http. Just add it to the cli folder named something like kewlcomponent.php. <?php /** * This is a CRON script ...
David Hayes's user avatar
2 votes

How to get menu parameters and itemid in component controller

To get Menu Params This one is perfect I was searching few hrs and this solve my issue of Joomla 3.6.5 & PHP 7.1 0: Using $this when not in object context Solution: $app = JFactory::...
RadiusTheme's user avatar
2 votes

Sharing a model between two views in a component

OK, comments are not the easiest place to talk in details (too short, too easy to misinterpret) so I'll post this here. It may be a bit wide-ranging and high-concept at first b/c of the lack of detail ...
Arlen's user avatar
  • 802
2 votes

Error JLIB_APPLICATION_ERROR_INVALID_CONTROLLER from CLI on Joomla 3.7

Start by updating to the latest version of Joomla - 3.9.20 - if you're able to first. A number of changes regarding JControllerLegacy were made in Joomla 3.8 (see https://github.com/joomla/joomla-cms/...
Patrick Jackson's user avatar
1 vote
Accepted

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

The comment from @mickmackusa is essentially correct, but there's some context missing, perhaps, from your question that makes me wonder if you're not asking a wider question. There are wide variety ...
Arlen's user avatar
  • 802
1 vote
Accepted

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

I never figured out how to use $this, but it was pretty straightforward otherwise. This checks to see if the add method exists in the Article controller. $ToolsClass = 'ContentControllerArticle'; $...
GDP's user avatar
  • 7,705
1 vote

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

Use your controller only for redirection purpose. For database stuff use your view model. Make sure your view name, controller file name, model file name are same. Form: <form method="post" class=...
user2980415's user avatar
1 vote

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

"file" is the frontend controller called here. /components/com_your_component/controllers/file.php class Your_ComponentControllerFile extends JControllerLegacy { public function submit(){ ...
Dennis Heiden's user avatar
1 vote
Accepted

Override View path in the Controller is only partially working

I think you need to path 'template_path' in the config as well. Probably something like $config['template_path'] = array( JPATH_COMPONENT.'/views/tmpl', $custom_view_path.'/tmpl', /* ...
David Hayes's user avatar
1 vote

Form-Validation in Frontend

It appears you are submitting the from without executing the validation. Using jQuery, you could listen for the form submit event, check validation and submit the form if it passes. At the top of ...
Brian Bolli's user avatar
  • 1,406
1 vote

Call Controller's Publish-Method from CLI or Helper

You can use the ComponentHelper class for this: class MyCliApp extends JApplicationCli { public function doExecute() { // Fool Joomla factory into loading CMS application ...
John Rix's user avatar
  • 537
1 vote

Create Dialog on publishing methods

The simplest way to implement a Confirmation dialog is on the client side, with Javascript routine. You can check how JToolbar does it: $bar = JToolbar::getInstance('toolbar'); // Add a ...
Anibal's user avatar
  • 7,415
1 vote

Insert query not working within a loop

An Table with 100 cols, should not be handled by hand.In most cases is something forgotten. On Changes you have heavy task to find in code the Positions Basically us the JForm with the correct Data-...
JProof's user avatar
  • 196
1 vote
Accepted

Controller error: Invalid controller: name='dasdada'

It's probably because of textarea name, don't use 'task' which is in use for controller routing requests, try "mytask" or whatever, and update references elsewhere in the code
Marko D's user avatar
  • 471
1 vote

Call controller's publish-function from "outside"

Recently i made a component when i change the o publish status via Ajax request. I made a method setPublish($id, $status) on model, and two methods on my controller: public function setPublishTrue()...
Guilherme's user avatar
  • 347
1 vote

Call controller's publish-function from "outside"

Yes, it is possible, but your have to create your own CLI script to translate the command line to the Joomla API command. For example: To receive a list of IDs (comma separated) from an argument ...
Anibal's user avatar
  • 7,415

Only top scored, non community-wiki answers of a minimum length are eligible