How to add autounpublish to module

Discussion and education for beginner / novice programmers interested in embarking on the development process to take advantage of the extensible nature of the Joomla! CMS.
Locked
Rene vK
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Sun Jun 11, 2006 12:04 pm
Location: Rotterdam, the Netherlands

How to add autounpublish to module

Post by Rene vK » Mon Aug 11, 2008 10:16 pm

Hi,

I have made a custom announcement module. It works great and now I would like to enhance it. One of the things I would like to add is a way to type in an end date so the module will unpublish itselves when that date is reached. But were do I start. Do I have to use a standard plugin and how will I call that function?

thx in advance, Rene

User avatar
tcp
Joomla! Ace
Joomla! Ace
Posts: 1548
Joined: Wed Sep 21, 2005 9:25 am
Location: Thailand
Contact:

Re: How to add autounpublish to module

Post by tcp » Thu Aug 14, 2008 4:23 pm

Slightly offtopic, so moving to the Coding 101 board.
Your solution for a single-page checkout on any website.
http://moolah-ecommerce.com

User avatar
tcp
Joomla! Ace
Joomla! Ace
Posts: 1548
Joined: Wed Sep 21, 2005 9:25 am
Location: Thailand
Contact:

Re: How to add autounpublish to module

Post by tcp » Thu Aug 14, 2008 4:29 pm

Rene vK wrote:Hi,

I have made a custom announcement module. It works great and now I would like to enhance it. One of the things I would like to add is a way to type in an end date so the module will unpublish itselves when that date is reached. But were do I start. Do I have to use a standard plugin and how will I call that function?

thx in advance, Rene
Seems like the best place to do this would be in your module code.
Your solution for a single-page checkout on any website.
http://moolah-ecommerce.com

Rene vK
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Sun Jun 11, 2006 12:04 pm
Location: Rotterdam, the Netherlands

Re: How to add autounpublish to module

Post by Rene vK » Mon Aug 18, 2008 1:04 pm

Indeed I want to insert the code in my own module but I need a lead on how to unpublish the module in mu template 'user5' location. I read thru the core plugins, modules & components to find some lead. The only two things I found were the load_module and code in com_content, which kills an article on a given date/time.
A lead to a solution would be enough, I would like to understand what is happening whem using a solution. My php is not to standard but in that way my knowledge will grow.

Rene vK
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Sun Jun 11, 2006 12:04 pm
Location: Rotterdam, the Netherlands

Re: How to add autounpublish to module

Post by Rene vK » Wed Aug 20, 2008 4:42 pm

all,

I did it, thx to Jisse Reitsma. He sent me the update query I had to use. undeneath you will find the code I use in my module!

Code: Select all

$einde = $params->get('einddag');
$edag = substr($einde,0,2);
$emnd = substr($einde,3,2);
$ejr = substr($einde,6,4);
$smneinde = $ejr . $emnd . $edag;
$nu = Date('d-[URL banned]');
$nudag = substr($nu,0,2);
$numnd = substr($nu,3,2);
$nujr = substr($nu,6,4);
$smnnu = $nujr . $numnd . $nudag;

$db	=& JFactory::getDBO();
$query = "UPDATE #__modules " .
		"\n SET published='0' " . 
		"\n WHERE position='user5' " .
		"\n AND module='mod_mededeling' " ;

if ($smneinde < $smnnu) {
	$db->setQuery( $query, 0);
	$db->query();}
else {	
	echo '<style type="text/css">';
	echo '
This thread can be closed.


Locked

Return to “Joomla! Coding 101”