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

TOPIC:

Publish function now gone, help! 05 Dec 2012 15:43 #5856

  • MorganL
  • MorganL's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
  • Posts: 438
  • Thank you received: 53
On a support role today

In a previous version of JCook not such a long time ago, we still had the Function Published() which allowed me to do other stuff with a record when it was published / unpublished when toggling on the grid layout.. In a fault system I created, if someone turned status to unpublished, it would record a lot more info.. example below
function publish($cid = array(), $publish = 1)
	{
		$user 	= JFactory::getUser();

		if (count( $cid ))
		{
			JArrayHelper::toInteger($cid);
			$cids = implode( ',', $cid );
			
			$user 	= JFactory::getUser();

			$query = 'UPDATE #__traindefectlogger_defects'
				. ' SET `published` = '.(int) $publish
				. ', `date_closed` = "'.date('y-m-j', time()).'"'
				. ', `time_closed` = "'.date('H:i:s', time()).'"'
				. ', `closed_by` = '.(int) $user->id
				. ' WHERE id IN ( '.$cids.' )'


			;
			$this->_db->setQuery( $query );
			if (!$this->_db->query()) {
				JError::raiseWarning(1000, $this->_db->getErrorMsg());
				return false;
			}
		}

		return true;
	}

as you can see when someone toggled to unpublished, it would record date, time, who did it.. awesome stuff!

In the latest iteration of JCook, this is just not possible as the publish function has gone, and is now just handled in the DOM HTML as a generic function

Can anyone give me a starting point for being to replicate the above custom publishing code for ONE view in the latest iteration of JCook
Morgan Leecy MCSE

Novell / Linux
PHP. MYSQL, Apache, node.js
Coldfusion, JQuery, HTML5
Joomla

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

Re: Publish function now gone, help! 05 Dec 2012 15:54 #5857

  • MorganL
  • MorganL's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
  • Posts: 438
  • Thank you received: 53
Oh OK.. I am on a roll herem need to work stuff through before asking. I looked at the DOM code and found that the old version and new version were still identical for publishing.. so I took a gamble

IF you define a function called publish in the model, the system will use it.. so I was able to just post the code I supplied above in the item model, and it just worked... I tested the model by removing the fuction and all that happened is the published toggled. With my code the user, date and time are recorded.. NICE

Clever stuff this J-Cook
Morgan Leecy MCSE

Novell / Linux
PHP. MYSQL, Apache, node.js
Coldfusion, JQuery, HTML5
Joomla

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

  • Page:
  • 1
Time to create page: 0.092 seconds
  I still don't believe he can really be human to do all this ! From all of the forums that I've ever participated in this is certainly the one that most encapsulates the feeling of being truly open source where everyone's opinions and contributions can and will shape the development of the service! It's truly awesome! Hope you enjoy cooking and look forward to reading and contributing to any of the editorial work that you proposed too!! Thanks
Gez (audibleid - JED)

Get Started