Здравствуйте!
Есть пару моментов которые хотелось бы исправить в ближайших версиях.
Судя по файлу administrator\components\com_menus\models\items.php в функции preprocessForm нет обработки плагина. Из-за этого нельзя добавить параметр в фильтр этой страницы.
Сделайте так, что бы можно было переопределять не только файл default.php но и все файлы которые начинаются на view (view.html.php, view.json.php, view.row.php).
Сделайте общее событие плагина (к примеру onContentDBQuery($context, $query, $db)). В этом событии можно будет изменять SQL запрос для своих нужд, что бы не лазить в ядре...
Google Translate (ru => en)
Minor improvements and changes to v3.x.x
Hello!
There are a couple of points that I would like to correct in the next versions.
Judging by the file administrator \ components \ com_menus \ models \ items.php in the function preprocessForm there is no processing plug-in. Because of this, you can not add a parameter to the filter on this page.
Do this so that you can redefine not only the default.php file but also all the files that start on view (view.html.php, view.json.php, view.row.php).
Make a general plug-in event (for example onContentDBQuery ($ context, $ query, $ db)). In this event, you can change the SQL query for your needs, that would not climb in the kernel ...
Labels |
Added:
?
|
Status | New | ⇒ | Discussion |
Category | ⇒ | com_menus |
@motokraft can you please translate in English so other can understand this issue?
Title |
|
Just done that with GT ;) But the points by michael still stands.
It is not clear what you meant!
Will these changes be in test versions?
Do this so that you can redefine not only the default.php file but also all the files that start on view (view.html.php, view.json.php, view.row.php).
Use the addViewPath
method in the controller ;)
Make a general plug-in event (for example onContentDBQuery ($ context, $ query, $ db)). In this event, you can change the SQL query for your needs, that would not climb in the kernel ...
There are no intentions to do this as this is calling for trouble.
this method is only available on the controller?
Can I call the addViewPath method from the plugin?
Yes. But you have to be very careful with this because the calls to JControllerLegacy::getInstance()
create a singleton instance and can mess up a component if not handled correctly. You will need a system plugin hooking the onAfterRoute
event, this code example should work for com_content
:
public function onAfterRoute()
{
$option = JFactory::getApplication()->input->getCmd('option');
switch ($option) {
case 'com_content':
$controller = JControllerLegacy::getInstance('Content');
$controller->addViewPath('/path/to/my/custom/views');
break;
}
}
and it is not easier to add a system plug-in event to the controller?
Indeed, in this model there are no triggers, one why he is needed there. Perhaps you want to make some useful filter and it should be added to core
What is the point? layout is enough, you can output the content as you like, in any format. Well at most, override controller.
It has already been many times. There will not be such. This is not com_k2. If you need to change the query, override model or create new component. If you add an event, the consequences can be too unpredictable
Okay! Good. Let's leave the controller alone and take care of the view itself, namely the files view.*.php.
You can do this so that you can redefine them as well as the default.php files
@motokraft I can not understand why you need to override the view.php entirely. You can tell more.
I make a template and I want to do on all pages where there is a table to use https://datatables.net/ together with ajax, but for this it is necessary to redefine the file view.html.php for each component and create a new file view.json.php
@motokraft You can use layout override & com_ajax with template helper. For this task, you do not need to override or create new view. This is if we are talking about templates.
If to speak about components as a whole for json it is better to use the controller with JResponseJson
Status | Discussion | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2018-05-18 22:59:35 |
Closed_By | ⇒ | Quy |
Closed_By | Quy | ⇒ | joomla-cms-bot |
Set to "closed" on behalf of @Quy by The JTracker Application at issues.joomla.org/joomla-cms/20300
Closing as it appears this issue has been answered.
Responding based on the Google translation for this:
For item 2, there is already a
addViewPath
method in controllers which lets you define additional filesystem paths to search for view classes. Beyond that, our API does not explicitly support overloading classes because this can (and will) cause problems with upgrades down the road, not to mention the inability to rely on a class being in a known state.For item 3, we do not have events in core which allows general query manipulation and we will not be adding these. That is just asking for too much trouble.