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:
...
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 ...
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 ...
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-&...
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' =...
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 ...
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('...
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.
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.
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 = ...
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 ...
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 ...
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 ...
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::...
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 ...
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/...
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 ...
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';
$...
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=...
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(){
...
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',
/* ...
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 ...
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
...
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 ...
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-...
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
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()...
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
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
controller × 42joomla-3.x × 13
component × 9
view × 9
model × 9
php × 5
custom-component × 5
development × 4
joomla-3.4 × 4
jform × 3
joomla-4.x × 3
mysql × 2
task × 2
plugin × 1
articles × 1
administrator × 1
joomla-api × 1
database × 1
overrides × 1
custom-field × 1
ajax × 1
url × 1
form × 1
redirect × 1
seo × 1