Archived talk

Difference between revisions of "Developing a MVC Component/Basic backend"

From Joomla! Documentation

m (→‎JController::display: make my response more clear)
(10 intermediate revisions by 7 users not shown)
Line 1: Line 1:
 
Items to be adding/changed on this page:
 
Items to be adding/changed on this page:
 +
 +
TODO: Model needs getPagination method
  
 
Note that if using core J! javascript in a form, id="adminForm" must also be included.
 
Note that if using core J! javascript in a form, id="adminForm" must also be included.
Line 21: Line 23:
  
 
public function display($cachable=false,$urlparams=false)
 
public function display($cachable=false,$urlparams=false)
 +
 +
:I changed this on the main page as I too was getting errors due to the listed display() method not being compatible with the new definition of JController::display().  [[User:AnthonyGeoghegan|AnthonyGeoghegan]] ([[User talk:AnthonyGeoghegan|talk]]) 09:49, 29 May 2013 (CDT)
  
 
== How to access backend component & task icons not displaying ==
 
== How to access backend component & task icons not displaying ==
  
The tutorial is unclear on how to access the backend component.  I did not find it accessible via the administrator UI; however I could run the component with:  
+
The tutorial is unclear on how to access the backend component.  I believe it would be helpful to explain that the component can be accessed in 2 ways:
  
 +
1) URL e.g.
 
http://localhost/joomla/administrator/index.php?option=com_helloworld
 
http://localhost/joomla/administrator/index.php?option=com_helloworld
  
However, underneath the menu bar (Site, Users, Menu...), there is an empty toolbar without any task icons (e.g. Save, Save and Close, Close...).  So I can "check" id 1 (Hello World!) and/or id2 (Good bye World!), but then cannot "Save" since there are no task icons.   
+
2) The "hello-world" menu item under "Components" of the Administration application
 +
 
 +
 
 +
I believe it would also be helpful to note that this component only does 2 things:
 +
 
 +
a) lists the two options stored in the database: id 1 (Hello World!) and id2 (Good bye World!)
 +
 
 +
b) allows us to use checkboxes to select one or both options before selecting a task from the toolbar
 +
 
 +
But this model does not give us a toolbar (i.e. the toolbar is empty without icons) so that we can not do anything with the option item(s) we select.  So I can "check" id 1 (Hello World!) and/or id2 (Good bye World!), but then cannot "Delete" them or "Edit" them since there are no task icons.   
 +
 
 +
It was also not clear to me that the option items we create with this backend component are the options that will then be available in the "Required Settings" section when Editing a Menu Item.  i.e. when I add a Menu Item and select "Menu Item Type": "COM_HELLOWORLD_HELLOWORLD_VIEW_DEFAULT_TITLE" (part 06 site component), the "Required Settings" drop-down box will contain the options that were created/edited with this backend component (well, at least that WILL be the case when we have a toolbar that gives us a "New" and "Delete" task icons which Part 09 shows us how to do)
 +
SAbboushi 6/25/2012
 +
 
 +
I would find it helpful if JHtml::_ were explained in a little more detail. In particular an explanation of the parameter 'grid.id' might help to understand the code rather than just copy and trust.
 +
 
 +
[[User:Neo314|Neo314]] ([[User talk:Neo314|talk]]) 02:09, 24 December 2012 (CST)
 +
 
 +
== Populatestate ==
 +
I'm not sure on how to add to the discussion.
  
Is this backend supposed to configure the "Required Settings" options when Editing a Menu Item?  i.e. when I add a Menu Item and select "Menu Type", is the purpose of this backend component to specify what options I have in the "Required Settings" drop-down box?
+
The weird comment here about _populateState() seems to be the introduction to a paragraph about this method; from my understanding, what it will do is be able to select specific fields, limits, additional where clauses,etc (Say, I want this table to display things only from a specific category - that should be done with populate state, it seems).
  
I have identified (hopefully) some outstanding obstacles to getting this backend component to function in 2.5; I hope someone knowledgeable can address these issues so Part 07 becomes a more effective tutorial.
+
Taken from com_content/site/models/articles.php if you were wondering,that's what i can read there.

Revision as of 09:57, 29 May 2013

Items to be adding/changed on this page:

TODO: Model needs getPagination method

Note that if using core J! javascript in a form, id="adminForm" must also be included.

Shouldn't references to $db->getDBO() be changed to $db->getDbo() ?

And what is this comment referring to? "The _populateState method is, by default, automatically called when a state is read by the getState method."

Radiant tech 06:37, 1 September 2011 (CDT)

Admin Forms in J2.5[edit]

Aparently, for the JToolbar Icons to work properly in J2.5, the form elements need the id "adminForm" to be assigned to them. I changed this in admin/views/helloworlds/tmpl/default.php. However, it also needs to be changed in the packages...

JController::display[edit]

The function declaration has been changed from

public function display($cachable=false)

TO

public function display($cachable=false,$urlparams=false)

I changed this on the main page as I too was getting errors due to the listed display() method not being compatible with the new definition of JController::display(). AnthonyGeoghegan (talk) 09:49, 29 May 2013 (CDT)

How to access backend component & task icons not displaying[edit]

The tutorial is unclear on how to access the backend component. I believe it would be helpful to explain that the component can be accessed in 2 ways:

1) URL e.g. http://localhost/joomla/administrator/index.php?option=com_helloworld

2) The "hello-world" menu item under "Components" of the Administration application


I believe it would also be helpful to note that this component only does 2 things:

a) lists the two options stored in the database: id 1 (Hello World!) and id2 (Good bye World!)

b) allows us to use checkboxes to select one or both options before selecting a task from the toolbar

But this model does not give us a toolbar (i.e. the toolbar is empty without icons) so that we can not do anything with the option item(s) we select. So I can "check" id 1 (Hello World!) and/or id2 (Good bye World!), but then cannot "Delete" them or "Edit" them since there are no task icons.

It was also not clear to me that the option items we create with this backend component are the options that will then be available in the "Required Settings" section when Editing a Menu Item. i.e. when I add a Menu Item and select "Menu Item Type": "COM_HELLOWORLD_HELLOWORLD_VIEW_DEFAULT_TITLE" (part 06 site component), the "Required Settings" drop-down box will contain the options that were created/edited with this backend component (well, at least that WILL be the case when we have a toolbar that gives us a "New" and "Delete" task icons which Part 09 shows us how to do) SAbboushi 6/25/2012

I would find it helpful if JHtml::_ were explained in a little more detail. In particular an explanation of the parameter 'grid.id' might help to understand the code rather than just copy and trust.

Neo314 (talk) 02:09, 24 December 2012 (CST)

Populatestate[edit]

I'm not sure on how to add to the discussion.

The weird comment here about _populateState() seems to be the introduction to a paragraph about this method; from my understanding, what it will do is be able to select specific fields, limits, additional where clauses,etc (Say, I want this table to display things only from a specific category - that should be done with populate state, it seems).

Taken from com_content/site/models/articles.php if you were wondering,that's what i can read there.