简体   繁体   中英

Joomla component application flow

I am new to Joomla component developement and currently fighting with certain basic design patterns! Lets say, I am developing a component where users can enter simple notes into their personal notebooks.

On calling the view "index.php?option=com_notebook&view=notes" I simply show a list of all note entries of the user. No problem so far, this is working fine.

Now I want to extend my component with the following feature: on opening the view "index.php?option=com_notebook&view=notes", I want to check if the user has already created a notebook before. If yes, I show all note entries, if not, I want to load a different view which contains a form to create a new notebook with certain options.

But how can this be done in a clean way? For sure, I just can implement the form within the view "notes", but this is not the clean way, isnt it? I also tried to override the function "display()" of the main controller and set the view manually if no notebook exists. But if I do so, I have to handle all calls to other views of my component manually within the function "display()". To solve this, I created a copy the original implementation from the class "JControllerLegacy" and changed it to my needs - this is working - but is this really the best way to handle problems like this?

So I ask you, what is the best approach to solve this problem? Thx a lot!

According to me the best solution of your problem is to provide "New" and "Edit" button to your notebook listing page and create edit view of notbook. Same as Joomla has articles and article views. So, As you mentioned above if use dose not have any notebook then he/she can create a new notebook using that "New" button. when user clicked on "New" button he has blank form where he/she can create new notebook. here is the example how to create listing and edit view in Joomla. Hope this will help you.

https://docs.joomla.org/J3.x:Developing_an_MVC_Component/Adding_backend_actions

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM