Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

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

  • arnar
  • arnar's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 20
  • Thank you received: 1
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
The following user(s) said Thank You: edwardcox

Please Log in or Create an account to join the conversation.

Last edit: by arnar.

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

+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.

Please Log in or Create an account to join the conversation.

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

  • arnar
  • arnar's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 20
  • Thank you received: 1
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();

Please Log in or Create an account to join the conversation.

Last edit: by arnar.
  • Page:
  • 1
Time to create page: 0.059 seconds

The j-cook project is one of the best of its kind and it is nice that we all try to contribute in little ways to make life easy for each other.

vlemos (Forum)  

Get Started