Welcome, Guest
Username: Password: Remember me

TOPIC: Publish function now gone, help!

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

  • MorganL
  • MorganL's Avatar
  • Offline
  • Platinum Member
  • Posts: 438
  • Thank you received: 53
  • Karma: 15
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
The administrator has disabled public write access.

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

  • MorganL
  • MorganL's Avatar
  • Offline
  • Platinum Member
  • Posts: 438
  • Thank you received: 53
  • Karma: 15
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
The administrator has disabled public write access.
Time to create page: 0.070 seconds

Get Started