I know that *delete* method of *persons* class do the job. But I would like
to know how this method get the id of the record ?? how the id pass to the
method ??
On Fri, Aug 10, 2012 at 4:26 PM, JSamir <samirabul...@gmail.com> wrote:
> As far as i know, there is some JavaScript attached to this button which
> sets some hidden fields. Check it with firebug.
> Am Freitag, 10. August 2012 12:20:37 UTC+2 schrieb nowphp:
>> I mean how this button send delete request to database ??
>> Thanks
>> Foysal
> --
> You received this message because you are subscribed to the Google Groups
> "Joomla! General Development" group.
> To view this discussion on the web, visit
> https://groups.google.com/d/msg/joomla-dev-general/-/8UNPSccLtFQJ.
> To post to this group, send an email to
> joomla-dev-general@googlegroups.com.
> To unsubscribe from this group, send email to
> joomla-dev-general+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/joomla-dev-general?hl=en-GB.
Hi, Foysal,
When you check the check boxes , and press the delete button, the task
hidden field of the form is set to person.delete, where delete method in
the person controller, there will be check box array is passed which name
is cid, this id can be taken from the delete function in the person
controller in the following way
> To post to this group, send an email to
> joomla-dev-general@googlegroups.com.
> To unsubscribe from this group, send email to
> joomla-dev-general+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/joomla-dev-general?hl=en-GB.
> Hi, Foysal,
> When you check the check boxes , and press the delete button, the task
> hidden field of the form is set to person.delete, where delete method in
> the person controller, there will be check box array is passed which name
> is cid, this id can be taken from the delete function in the person
> controller in the following way
>> To post to this group, send an email to
>> joomla-dev-general@googlegroups.com.
>> To unsubscribe from this group, send email to
>> joomla-dev-general+unsubscribe@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/joomla-dev-general?hl=en-GB.
> --
> You received this message because you are subscribed to the Google Groups
> "Joomla! General Development" group.
> To post to this group, send an email to
> joomla-dev-general@googlegroups.com.
> To unsubscribe from this group, send email to
> joomla-dev-general+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/joomla-dev-general?hl=en-GB.
I am learning joomla 2.5 mvc component developing . But my delete button
of admin panel is not working. What can be the cause ?? I searched a lot in
google but could not get any soultion. Can anyone say where is the problem
??
Thanks
Foysal
On Fri, Aug 10, 2012 at 5:19 PM, MOHAMED AKRAM <mohamedakra...@gmail.com>wrote:
> Hi, Foysal,
> When you check the check boxes , and press the delete button, the task
> hidden field of the form is set to person.delete, where delete method in
> the person controller, there will be check box array is passed which name
> is cid, this id can be taken from the delete function in the person
> controller in the following way
>> To post to this group, send an email to
>> joomla-dev-general@googlegroups.com.
>> To unsubscribe from this group, send email to
>> joomla-dev-general+unsubscribe@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/joomla-dev-general?hl=en-GB.
> --
> You received this message because you are subscribed to the Google Groups
> "Joomla! General Development" group.
> To post to this group, send an email to
> joomla-dev-general@googlegroups.com.
> To unsubscribe from this group, send email to
> joomla-dev-general+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/joomla-dev-general?hl=en-GB.
Could you be a bit more specific: what happens and what not, under which circumstances? What have you done so far to test what happens? And maybe some code would be helpful too.
For now it is not clear to me what the problem is. I assume you have a MVC-component with a JTable and added a delete-button in the toolbar, but when you push that button nothing happens (that is: is the page not submitted at all? Or is it, but afterwards returns to the same page without the deletes being done?
On Sunday, 12 August 2012 08:54:38 UTC+2, nowphp wrote:
> Hi all,
> I am learning joomla 2.5 mvc component developing . But my delete button > of admin panel is not working. What can be the cause ?? I searched a lot in > google but could not get any soultion. Can anyone say where is the problem > ??
Thanks for your valuable reply. I am new in joomla 2.5 component
development that's why it is little more problematic for me to be specific.
I visited your link and some other tutorials then I am trying to develop a
component using knowledge of those tutorials. But delete button of admin
panel is not working.That means when I push that button nothing happens.
*Where can I start my checking ?? *
I am pasting some code for you.
in controllers folder
paper.php
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import Joomla controllerform library
jimport('joomla.application.component.controllerform');
class TestControllerPaper extends JControllerForm
{
}
papers.php
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import Joomla controlleradmin library
jimport('joomla.application.component.controlleradmin');
class TestControllerPapers extends JControllerAdmin
{
/**
* Set default values when no action is specified (ie for cancel)
*/
public function getModel($name = 'Papers',
$prefix = 'TestModel', $config = array())
{
return parent::getModel($name, $prefix, $config);
}
}
in model folder
papers.php
<?php
defined('_JEXEC') or die();
jimport( 'joomla.application.component.modeladmin' );
class TestModelPapers extends JModelAdmin
{
public function getForm($data = array(), $loadData = true)
{
}
}
in tables folder
paper.php
<?php
// No direct access
defined('_JEXEC') or die('Restricted access');
class TablePaper extends JTable
{
function __construct( &$db ) {
parent::__construct('#__registry_persons', 'id', $db);
}
> Could you be a bit more specific: what happens and what not, under which
> circumstances? What have you done so far to test what happens? And maybe
> some code would be helpful too.
> For now it is not clear to me what the problem is. I assume you have a
> MVC-component with a JTable and added a delete-button in the toolbar, but
> when you push that button nothing happens (that is: is the page not
> submitted at all? Or is it, but afterwards returns to the same page without
> the deletes being done?
> On Sunday, 12 August 2012 08:54:38 UTC+2, nowphp wrote:
>> Hi all,
>> I am learning joomla 2.5 mvc component developing . But my delete button
>> of admin panel is not working. What can be the cause ?? I searched a lot in
>> google but could not get any soultion. Can anyone say where is the problem
>> ??
> To post to this group, send an email to
> joomla-dev-general@googlegroups.com.
> To unsubscribe from this group, send email to
> joomla-dev-general+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/joomla-dev-general?hl=en-GB.
Thank you very much, Foysal. Unfortunately I don't immediately see an error in the code you showed. So: or I overlooked it or it is somewhere else. Your question is where to start your checking. I'd take the following steps:
- look at the *source code* of the page with the delete button; FireBug can be of great help. Are all necessary ingredients there? - the checkboxes with something like <input type="checkbox" id="cb0" name ="cid[]" value="3" onclick="Joomla.isChecked(this.checked);" and that value must be the id of your person - the javascript-libraries like mootools and <script src=" /media/system/js/core.js<view-source:http://www.jug010.nl/media/system/js/core.js>" type="text/javascript"></script> - has the delete-button something like {Joomla.submitbutton('remove');} in the onclick attribute? - are there any *error-messages*? If something is wrong in Javascript, all further Javascript stops. You can find errors in Javascript in an Error Console of your browser (I use FireFox with all kinds of developer addons). You could also raise the error-reporting level of PHP to get PHP errors. In Joomla you can also put debugging on; then you can for instance see all db-queries. - and then the real *debugging*. In an IDE you could use XDebug, trace everything, set breakpoints etc., but that takes some time to get it in your fingers. But you can always do a simple "echo and die" debug to see if the program arrived somewhere and what the value of variables was at a particular point. Just echo values (or print_r for arrays or var_dump for whole objects). If a string is empty you won't see anything, so put something around that variable to see the spot where something should be printed. It can also be, that the program is redirected after your echo-statement; then you also would seen nothing. In that case: use die() to halt the program.
All 3 methods can be summarised as: looking "under water"; what is happening under the hood? Sometimes it takes longer, sometimes shorter, but you'll always find what is wrong. Debugging is an unseparable part of programming.
On Monday, 13 August 2012 17:32:11 UTC+2, nowphp wrote:
> Dear Herman,
> Thanks for your valuable reply. I am new in joomla 2.5 component > development that's why it is little more problematic for me to be specific.
> I visited your link and some other tutorials then I am trying to develop a > component using knowledge of those tutorials. But delete button of admin > panel is not working.That means when I push that button nothing happens.
> *Where can I start my checking ?? *
> I am pasting some code for you.
> in controllers folder
> paper.php
> <?php > // No direct access to this file > defined('_JEXEC') or die('Restricted access'); > // import Joomla controllerform library > jimport('joomla.application.component.controllerform'); > class TestControllerPaper extends JControllerForm > { > }
> papers.php
> <?php > // No direct access to this file > defined('_JEXEC') or die('Restricted access'); > // import Joomla controlleradmin library > jimport('joomla.application.component.controlleradmin'); > class TestControllerPapers extends JControllerAdmin > { > /** > * Set default values when no action is specified (ie for cancel) > */ > public function getModel($name = 'Papers', > $prefix = 'TestModel', $config = array()) > { > return parent::getModel($name, $prefix, $config); > } > }
> in model folder
> papers.php
> <?php > defined('_JEXEC') or die(); > jimport( 'joomla.application.component.modeladmin' ); > class TestModelPapers extends JModelAdmin > { > public function getForm($data = array(), $loadData = true) > { > } > }
> in tables folder
> paper.php
> <?php > // No direct access > defined('_JEXEC') or die('Restricted access'); > class TablePaper extends JTable > { > function __construct( &$db ) { > parent::__construct('#__registry_persons', 'id', $db); > } > }
Thanks Herman, for your long valuable reply. I checked my code again and
again found that I didn't write a line that is "<input type="hidden"
name="boxchecked" value="0" />" .
But right now I am getting following error
500 - An error has occurred.
View not found [name, type, prefix]: papers, html, testView
> Thank you very much, Foysal. Unfortunately I don't immediately see an
> error in the code you showed. So: or I overlooked it or it is somewhere
> else.
> Your question is where to start your checking.
> I'd take the following steps:
> - look at the *source code* of the page with the delete button;
> FireBug can be of great help. Are all necessary ingredients there?
> - the checkboxes with something like <input type="checkbox" id="cb0"
> name="cid[]" value="3" onclick="Joomla.isChecked(this.checked);" and
> that value must be the id of your person
> - the javascript-libraries like mootools and <script src="
> /media/system/js/core.js" type="text/javascript"></script>
> - has the delete-button something like
> {Joomla.submitbutton('remove');} in the onclick attribute?
> - are there any *error-messages*? If something is wrong in Javascript,
> all further Javascript stops. You can find errors in Javascript in an Error
> Console of your browser (I use FireFox with all kinds of developer addons).
> You could also raise the error-reporting level of PHP to get PHP errors. In
> Joomla you can also put debugging on; then you can for instance see all
> db-queries.
> - and then the real *debugging*. In an IDE you could use XDebug, trace
> everything, set breakpoints etc., but that takes some time to get it in
> your fingers. But you can always do a simple "echo and die" debug to see if
> the program arrived somewhere and what the value of variables was at a
> particular point. Just echo values (or print_r for arrays or var_dump for
> whole objects). If a string is empty you won't see anything, so put
> something around that variable to see the spot where something should be
> printed. It can also be, that the program is redirected after your
> echo-statement; then you also would seen nothing. In that case: use die()
> to halt the program.
> All 3 methods can be summarised as: looking "under water"; what is
> happening under the hood? Sometimes it takes longer, sometimes shorter, but
> you'll always find what is wrong. Debugging is an unseparable part of
> programming.
> I'm curious what went wrong. Please let us know.
> Ciao,
> Herman
> On Monday, 13 August 2012 17:32:11 UTC+2, nowphp wrote:
>> Dear Herman,
>> Thanks for your valuable reply. I am new in joomla 2.5 component
>> development that's why it is little more problematic for me to be specific.
>> I visited your link and some other tutorials then I am trying to develop
>> a component using knowledge of those tutorials. But delete button of admin
>> panel is not working.That means when I push that button nothing happens.
>> *Where can I start my checking ?? *
>> I am pasting some code for you.
>> in controllers folder
>> paper.php
>> <?php
>> // No direct access to this file
>> defined('_JEXEC') or die('Restricted access');
>> // import Joomla controllerform library
>> jimport('joomla.application.**component.controllerform');
>> class TestControllerPaper extends JControllerForm
>> {
>> }
>> papers.php
>> <?php
>> // No direct access to this file
>> defined('_JEXEC') or die('Restricted access');
>> // import Joomla controlleradmin library
>> jimport('joomla.application.**component.controlleradmin');
>> class TestControllerPapers extends JControllerAdmin
>> {
>> /**
>> * Set default values when no action is specified (ie for cancel)
>> */
>> public function getModel($name = 'Papers',
>> $prefix = 'TestModel', $config = array())
>> {
>> return parent::getModel($name, $prefix, $config);
>> }
>> }
>> in model folder
>> papers.php
>> <?php
>> defined('_JEXEC') or die();
>> jimport( 'joomla.application.component.**modeladmin' );
>> class TestModelPapers extends JModelAdmin
>> {
>> public function getForm($data = array(), $loadData = true)
>> {
>> }
>> }
>> in tables folder
>> paper.php
>> <?php
>> // No direct access
>> defined('_JEXEC') or die('Restricted access');
>> class TablePaper extends JTable
>> {
>> function __construct( &$db ) {
>> parent::__construct('#__**registry_persons', 'id', $db);
>> }
>> }
> To post to this group, send an email to
> joomla-dev-general@googlegroups.com.
> To unsubscribe from this group, send email to
> joomla-dev-general+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/joomla-dev-general?hl=en-GB.
On Wednesday, 15 August 2012 11:12:44 UTC+2, nowphp wrote: > View not found [name, type, prefix]: papers, html, testView
> I think joomla is looking for TestViewPapers. > *But why joomla looking for TestViewPapers ?? > Where did I mention to look for TestViewPapers ??*
Allright, we are almost there!
You are completely right that Joomla! looks for a class TestViewPapers here. You didn't have to mention it: it is looked for "automagically". This style of programming is called "Convention over Code" (CoC): as long as you follow the conventions, you don't have to write any code for it. If you want another name for your view, you'll have to put that in the code (i.c. with the controller's getView() method).
The advantage of CoC is that you have to write less code. The disadvantage is that you have to know the conventions. In this case: that if you don't specify the class name of the view, Joomla! will look for a class named * [component_name]View[view_name]* in the file view.html.php in the folder views/[view_name] of your component, where the view_name is the same as the model_name and the controller_name if not specified otherwise. In this case your component_name is "test" (without the com_) and your view_name is "papers". Another convention is that all file-paths are small case, but for the class you use uppercase for the first character of the three pieces (so: TestViewPapers and not testviewpapers. Which would often not be a problem, for PHP is case sensitive, but not for class names. Still, you better get used to it to avoid some hard to find bugs).
There are frameworks that use the CoC-principle more widely than the Joomla!-platform. For instance Nooku Framework, which can be used besides the Joomla!-platform to make extensions for Joomla!. It will give you a 40 - 80 % code reduction; but because you first have to learn some conventions you also have a steeper learning curve (and you just experience the steepness of Joomla!'s learning curve right now). We have a Dutch football-player who is as well known for his way of saying things as for the way he played and he used to say: "every advantage has it's disadvantage" (or the other way around) and that is certainly true for Convention over Code!