Welcome, Guest
Username: Password: Remember me

TOPIC: [ADDED] Custom Bricks

[ADDED] Custom Bricks 26 Jul 2012 10:03 #2902

  • arnar
  • arnar's Avatar
  • Offline
  • Junior Member
  • Posts: 20
  • Thank you received: 1
  • Karma: 0
Hi,

I believe it would be useful to add the following bricks.
  1. Save & New. Works similar to Save & Close except it Saves and opens up a empty sheet.
  2. Save & Clone. Works similar to 1. except it Saves and opens up a copy of the Saved item with a new id.
  3. Custom Brick with label. Then once published the user could just call code from the brick action. It would make it easier to automatically replace code instead of having to manually change the files after publish.


Regards
Arnar
Last Edit: 26 Jul 2012 10:03 by arnar.
The administrator has disabled public write access.
The following user(s) said Thank You: edwardcox

Re: Custom Bricks 26 Jul 2012 12:47 #2907

  • edwardcox
  • edwardcox's Avatar
  • Offline
  • Premium Member
  • Here to help.
  • Posts: 131
  • Thank you received: 26
  • Karma: 12
+1 from me, I like the way he is thinking.

Edward.
Passionate Joomla! Developer and J-Cook pro evangelist.
www.jcombuilder.com - we build great Joomla!® Components so you don't have to.
The administrator has disabled public write access.

Re: Custom Bricks 26 Jul 2012 16:48 #2908

  • arnar
  • arnar's Avatar
  • Offline
  • Junior Member
  • Posts: 20
  • Thank you received: 1
  • Karma: 0
The save & new code is really simple

in view form add
if ($access->get('core.edit') || ($isNew && $access->get('core.create') || $access->get('core.edit.own')))
			$bar->appendButton( 'Standard', "save-new", "JTOOLBAR_SAVE_AND_NEW", "save2new", false);

then in controller add
in constructor
        $this->registerTask( 'save2new', 'save' );

in save function
        $task = $this->getTask();

      		if ($cid = parent::_save($post))
		{
			$vars = array();

            if ($task == 'save2new') {
                
                JRequest::setVar( 'cid', 0 );
                JRequest::setVar( 'view'  , 'clubitem');
                JRequest::setVar( 'layout', 'clubitem' );
            }
            else
            {
			    JRequest::setVar( 'view'  , 'clubs');
			    JRequest::setVar( 'layout', 'default' );
			    JRequest::setVar( 'cid', null );
            }
			$this->setRedirect(LpadHelper::urlRequest($vars));
		}
		else
			//Keep the post and stay on page
			parent::display();
Last Edit: 26 Jul 2012 18:50 by arnar.
The administrator has disabled public write access.
Time to create page: 0.090 seconds

Get Started