The Joomla! Forum ™



Forum rules


Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.



Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Wed Aug 04, 2010 12:11 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Wed Sep 23, 2009 12:06 pm
Posts: 16
When I save an article, I need the Created date to automatically match the Start Publishing date the user set while writing the article. How can I go about doing this?


Top
 Profile  
 
PostPosted: Wed Aug 04, 2010 2:35 pm 
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Fri Jul 17, 2009 9:09 am
Posts: 111
I think you could do it with a plugin without hacking the core.

Otherwise just enter it manually :)


Top
 Profile  
 
PostPosted: Wed Aug 04, 2010 2:38 pm 
Joomla! Explorer
Joomla! Explorer

Joined: Mon Aug 11, 2008 3:05 pm
Posts: 459
You could just write a quick little onBeforeContentSave plugin.

Craig


Top
 Profile  
 
PostPosted: Wed Aug 04, 2010 2:43 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Wed Sep 23, 2009 12:06 pm
Posts: 16
I have gotten both of those answers before, I need something more specific though! There are a lot of articles posted daily on the site and therefore I do not want to do it manually every day. Can you elaborate on how to write that plugin? I've read the tutorial and understand the basics but I do not know what PHP? Javascript? I would write to make the dates match


Top
 Profile  
 
PostPosted: Wed Aug 04, 2010 3:37 pm 
Joomla! Explorer
Joomla! Explorer

Joined: Mon Aug 11, 2008 3:05 pm
Posts: 459
This is how the core of the plugin could be written
Code:
class plgContentCreated_Modified extends JPlugin
{
   function plgContentCreated_Modified( &$subject, $params )
   {
      parent::__construct( $subject, $params );
   }

   function onBeforeContentSave( &$article, &$params)
   {
      //$article->created = $article->modified;
      $article->created = $article->publish_up;
   }
}


I attached a plugin so you can just download and install it.

Craig
PS Oops I used modified in the plugin, just change it to publish_up
Attachment:
plg_created_modified.zip


You do not have the required permissions to view the files attached to this post.


Top
 Profile  
 
PostPosted: Wed Aug 04, 2010 5:00 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Wed Sep 23, 2009 12:06 pm
Posts: 16
Craig, I cannot begin to thank you enough! I have been trying to figure out a solution to this problem for weeks now and although I knew what I needed to do, I just wasn't able to put it together like you did. Thank you! I really appreciate it.


Top
 Profile  
 
PostPosted: Thu Aug 26, 2010 11:57 pm 
User avatar
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Aug 26, 2010 11:27 pm
Posts: 14
Location: CA-US
thanks, i needed this also


Top
 Profile  
 
PostPosted: Mon Apr 23, 2012 12:07 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Fri May 13, 2011 8:23 am
Posts: 1
Thanks too!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 



Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group