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
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,812
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 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

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
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
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,715
1 vote

Folders inside src/Controller/ folder

One way to do this, in your Controller folder: class BranchController extends FormController { public function update_localgroup() { $file = JPATH_COMPONENT . '/src/Controller/Branch/...
user3402785's user avatar
1 vote
Accepted

How to get user session info from external php script with Joomla-4.x?

The below code is mostly from Joomla's /includes/app.php but without the last line. The last few lines then get information about the user and the user session. <?php define('_JEXEC', 1); define('...
TryHarder's user avatar
  • 2,340
1 vote

Where does JControllerLegacy::redirect() redirect to?

It redirects to whatever is set in controller's $redirect property, normally using setRedirect() method. As an example, redirects are commonly used in form controllers. When saving an item fails, you ...
Sharky's user avatar
  • 11.1k
1 vote

Trigger controller method from another component

In Joomla when you call a controller's save() method (usually it is a FormController if it has a save() method) the controller's save() method calls the corresponding Model right away and the validate(...
Zollie's user avatar
  • 2,926
1 vote

Deleting rows in two different tables

You can definitely delete rows from multiple tables in a single query, but Joomla doesn't offer a query-building technique to accommodate this. If you absolutely demand that query builder methods must ...
mickmackusa's user avatar
  • 4,791
1 vote
Accepted

Deleting rows in two different tables

Why don't you do it in 2 steps? I would do something like the following code. As you can see I use name spacing (since Joomla 3.8), used quoteName the table + field names and added a try/catch block. ...
pe7er's user avatar
  • 2,023
1 vote
Accepted

Ajax Request returning the whole page not a specifc value

What you should do is include &format=json in your URL. This tells Joomla that you want a JSON response rather than HTML, and it won't run (subsequently) your template to produce all your page ...
Robbie Jackson's user avatar
1 vote

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

I don't know for sure, but I've thought of a reason why it makes sense, so here goes … Joomla components use FormController to handle whenever the (usually admin) user is editing an item and then ...
Robbie Jackson's user avatar
1 vote
Accepted

Add custom code to the controller from com_weblinks

Looking at how Weblinks works I can see that the only time weblinks.go gets involved is when you have have an option selected to count Hits for each link causing view.html.php to display this style of ...
Irata's user avatar
  • 3,822
1 vote
Accepted

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

It doesn't look like you are including the menu Itemid in your redirect which is why your URL is changing. Add another hidden field with the value of your current Itemid. Your redirect code is fine ...
Terry Carter's user avatar
  • 1,812
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,416
1 vote

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

This is because each search form change triggers form submit So you need to return "task" field to it's default value, wich is empty by default function submitForm(){ this.form.submit(); jQuery('...
Alexandr's user avatar
  • 1,130
1 vote

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

Check if you have hidden field named task if not then add following: <input type="hidden" value="" name="task"> Then change its value by editing on change event as follows: onchange="...
Lokendra Joshi's user avatar
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
  • 547

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