4th meeting Joomla GSoC 2016
By Private Profile 3ed3e09d on 2016-06-21 17:50 in GSoC 16 Improving the menu item workflow
Date: 21st Jun 2016 on Glip Chat
Time: 14:30 (UTC / GMT)
Meeting was attended by: Shubham Rajput, Gunjan Patel, Peter Martin, Puneet Kala
-
Presentation & Review done on work done last week
I was hoping to use JLoader:register to call the model. But as gunjan advised to use JModelAdmin:getinstance(‘menu’) to use com_menu item model into com_content article controller to call save method or menu item. JLoaderRegister loads the whole class whereas JModelAdmin:getinstance() returns the object through each a particular function can be accessed.
I was confused about how to save the menu item. Either to make a separate function in the article controller and then passing it to the menu model. Gunjan suggested to make use of the postSaveHook() function available in the article controller. The postSaveHook() provides the functionality of saving the menu data after article content is saved in the database. In this way the menu data can be saved just after article content is saved.
This week I faced some problems with some parts of the Joomla code. The JLoader path in the model/item.php was not set properly. Therefore he set it to correct path. He tried to send the $data of the article content, but that data is irrelevant for the menu model. Therefore made changes by forming a new set of data that is relevant to the menu model.
Faced some PHPCS errors which resulted Travis build failure (the code style checker integrated on Github) in github commits therefore he made amends in the code to make it according to joomla code style.
Joomla is giving a fatal error when after filling all the data in the article edit dialogue box the save button is clicked. Shubham tried to remove that error using this code at https://github.com/joomla-projects/gsoc16_menu-for-article/pull/6/files#diff-5395cbd1bcfceacc38880d9568f7427cL1276
JModelLegacy::addTablePath(JPATH_ADMINISTRATOR . '/components/com_menus/tables');
$table = JModelLegacy::getTable('Menu', 'MenusTable');
Even though this method removed the error but I was still facing the problem that the menu data is not saved in the database. Gunjan directed me in the way to look at JModelLegay functions and to come out with a solution. I went through the JModelLegacy functions to look for a solution. setLocation is showing an error because table it is missing at this position https://github.com/joomla-projects/gsoc16_menu-for-article/blob/staging/administrator/components/com_menus/models/item.php#L1276
So I thought I should look for a function that may include the missing table in the menu model. _construct(),_tostring(),addIncludePath() were not seemed connected with this problem.
I tried using setProperties() function to set the model object properties so that table can be formed in menu model part. But then again the data is received in the save($data) function of menu model using $data variable. addTablePath() Adds to the stack of model table paths in LIFO order. Maybe this would help by setting the model table path. So currently I am looking into more of these functions and trying out to find a solution. Gunjan and Peter gave me some tips regarding debugging.
-
Timeline & Tasks
I will work on making the menu link after saving the article. I will probably need max 2 days for that. After that I will try to make it more generic. Gunjan advised to make the menu title in the menu tab to be automatically filled with the title for menu (like the alias)
-
Open questions
I had one question regarding ID field in the xml file of both article and item. ID field is not filled by the user so how joomla assigns ID field a value? Gunjan & Peter explained about the database field autoincrement feature.
-
Resources to read suggested
https://docs.joomla.org/Using_nested_sets
http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/