0
votes

i know its sounds a bit crazy, but so many clients have problems with not saving their article properly.

I just wanted to use a simple method to trigger the onclick of the APPLY button inside a joomla article in edit mode.

Primarily back end editing as i have a good admin template that allows me to show clients the bare bones.

I know that by clicking apply the page reloads but thats better than nothing.

How on earth do i add do this?

I was hoping something like this would work but i dont quite know how to trigger a button that seems to reside inside a toolbar function of some sort.

I have this:

<script type="text/javascript">

 $(document).ready(function() {

 $('??????').trigger('click');

 });

</script>

What would replace the question marks?

Also i know i would need to put a timer into the jquery code but how do i get the link below to trigger?

http://mydomain.com/administrator/index.php?option=com_content&sectionid=1&task=edit&cid[]=97

In the toolbar.content.html.php file joomla has this:

class TOOLBAR_content
{
    function _EDIT($edit)
    {
        $cid = JRequest::getVar( 'cid', array(0), '', 'array' );
        $cid = intval($cid[0]);

        $text = ( $edit ? JText::_( 'Edit' ) : JText::_( 'New' ) );

        JToolBarHelper::title( JText::_( 'Article' ).': <small><small>[ '. $text.' ]</small></small>', 'addedit.png' );
        JToolBarHelper::preview( 'index.php?option=com_content&id='.$cid.'&tmpl=component', true );
        JToolBarHelper::save();
                                    /////////////////////////////////////
        JToolBarHelper::apply(); // < // THIS IS WHAT I WANT TO TRIGGER
                                    /////////////////////////////////////
        if ( $edit ) {
            // for existing articles the button is renamed `close`
            JToolBarHelper::cancel( 'cancel', 'Close' );
        } else {
            JToolBarHelper::cancel();
        }       

    }
...... more stuff here
}

I know this might sound crazy but wouldnt it be great if autosave could happen even without a reload, but i guess that would mean posting all the data using jquery rather than the php post and reload page method.

Anyways im not expecting a miracle here but if anyone could help that would be great.

Cheers in advance John

PS:

i just tried something like this hoping maybe it will work but it just reloads the page:

function autosave()
{
window.location = "index.php?option=com_content&sectionid=<?php echo $_GET['sectionid'];?>&task=edit&cid[]=<?php echo $row->id;?>"
}
1
i guess no one is willing to go there ... he he. I said it was crazy but hey... any one? bump :) - jonnypixel
jeepers @jonnypixel - we're not all on the same time zone as you... give me a few minutes to write up a reply. - Craig

1 Answers

1
votes
  1. You won't be able to do it without forcing a reload unless you decide to re-write the whole of com_content with an ajax implementation.

  2. Looking at the code you've posted I guessing Joomla! 1.5 - which by default has MooTools 1.12 or 1.2.5 (if you enabled the MooTools upgrade plugin in later versions of 1.5.x) - so more of a question but why not use that?

  3. You will have to modify the admin template to embed the JS you need, 1.5 has few triggers and none that are really worth using in the admin screens (unless you're up for a fair bit of PHP coding)

Somewhere in the <head> tag of com_content's Article view you will need to add this:

<script type="text/javascript">
    var interval = 30 //seconds
    var timer = setTimeout(submitbutton('apply'),(interval * 1000));
    }
</script>

Please note I haven't tried this just typed it straight into here.

  1. Since you're on 1.5 have you tried the Simple Content Versioning extension - it has autosave functionality that appears to be what you want - and probably works whereas who knows with my code in #3.