Support Forums

Listing reminder module

This is a discussion on Listing reminder module within the Modules / Plugins / Modifications forums, part of the Developer Forums category; I used the code below by CIV that reminded users of incomplete ads on my old v3.1 site that is ...


Go Back   68 Classifieds Forums > Developer Forums > Modules / Plugins / Modifications

Reply
 
Thread Tools Display Modes
Old 11-20-2009, 09:11 PM   #1
Customer
 
Join Date: Sep 2006
Location: USA
Posts: 156
Rep Power: 24
BigOrange will become famous soon enough
Default Listing reminder module

I used the code below by CIV that reminded users of incomplete ads on my old v3.1 site that is now closed. I really liked the way it worked. Now I'm putting together a new 68classified site using version 4.1.6. I know a reminder is available that sends emails but I really liked the old version that just displayed a reminder message. Has anyone updated the code below to work with version 4.1.6?

(To CIV, If you do not want this code updated I will respect your wishes as the author of the code.)

Code:
<?php
/*
 * Civ's Listing Status Reminder Module for 68Classifieds
 *
 * (c) Copyright 2006, Civ unless specifically noted otherwise.
 *
 * v1.0 (Initial Release)
 */
function ls_reminder_start() {
	if(($uid = (int)$_SESSION['uid']) == 0) return;
	global $db, $class_tpl;
  $reminderSQL = "SELECT display FROM ".PREFIX."products WHERE owner = ".$uid;
  $reminderResult=$db->query($reminderSQL);
  $rows=$reminderResult->size();
	for($i=1; $i<=$rows; $i++) { // loop through this user's listings
		$rs = $reminderResult->fetch();
		if ($rs['display'] == "C") { // do they have any "Not Completed" listings?
			$class_tpl->assign('reminder_display_not_completed', TRUE);
		}
		elseif($rs['display'] == "N") { // do they have any "Not Active" listings?
			$class_tpl->assign('reminder_display_not_active', TRUE);
		}
		elseif($rs['display'] == "E") { // do they have any "Expired" listings?
			$class_tpl->assign('reminder_display_expired', TRUE);
		}
	}  // for
}   
?>
__________________
v4.1.9 Designer - Default template (modified)

"I have never forgotten anything... if I have I can't remember what it was."
BigOrange is offline   Reply With Quote
Old 11-23-2009, 09:13 AM   #2
68 Classifieds Staff
 
Eric Barnes's Avatar
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,489
Rep Power: 135
Eric Barnes is just really nice Eric Barnes is just really nice
Default

I am guessing you could just change this line:
Code:
".PREFIX."products
to
Code:
".PREFIX."listings
__________________
Eric Barnes
68 Classifieds Developer
Customer Area | Issue Tracker | Documentation | 68C Mods | 68 @ Twitter | My Modules
Eric Barnes is offline   Reply With Quote
Old 11-23-2009, 11:47 AM   #3
Customer
 
Join Date: Sep 2006
Location: USA
Posts: 156
Rep Power: 24
BigOrange will become famous soon enough
Default

Quote:
Originally Posted by Eric Barnes
I am guessing you could just change this line:
Code:
".PREFIX."products
to
Code:
".PREFIX."listings
Eric, Thanks for the reply. That didn't get it to work. Below is the code that I have in home.tpl that worked in 3.1 The code I provided in my last post is located in: / modules/ ls_reminder .

The module is active in the Admin panel. Any ideas on what else needs to be done to get it to work? I'm not very good when it comes to accessing the database. Any help you can provided is appreciated.


Code:
<!-- Begin Listing Status Reminder -->
      {if $reminder_display_not_completed}
<center>Attention: One or more of your ads was not successfully completed.<br>
<a href="userbrowselistings.php"><b>Click here to complete your ad.</b></a></center>
      {/if}
<!-- END Listing Status Reminder -->
__________________
v4.1.9 Designer - Default template (modified)

"I have never forgotten anything... if I have I can't remember what it was."
BigOrange is offline   Reply With Quote
Old 11-23-2009, 12:23 PM   #4
68 Classifieds Staff
 
Eric Barnes's Avatar
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,489
Rep Power: 135
Eric Barnes is just really nice Eric Barnes is just really nice
Default

In v4.1 we changed the module system a little and now it uses a new hooks.php class file. That will probably need to be converted from the mod_user.php file.
__________________
Eric Barnes
68 Classifieds Developer
Customer Area | Issue Tracker | Documentation | 68C Mods | 68 @ Twitter | My Modules
Eric Barnes is offline   Reply With Quote
Old 11-23-2009, 12:37 PM   #5
Customer
 
Join Date: Sep 2006
Location: USA
Posts: 156
Rep Power: 24
BigOrange will become famous soon enough
Default

Quote:
Originally Posted by Eric Barnes
In v4.1 we changed the module system a little and now it uses a new hooks.php class file. That will probably need to be converted from the mod_user.php file.
That may be a little over my head. Is there any info available that might help me do that?
Thanks
__________________
v4.1.9 Designer - Default template (modified)

"I have never forgotten anything... if I have I can't remember what it was."
BigOrange is offline   Reply With Quote
Old 11-23-2009, 01:54 PM   #6
68 Classifieds Staff
 
Eric Barnes's Avatar
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,489
Rep Power: 135
Eric Barnes is just really nice Eric Barnes is just really nice
Default

You will need to know the basics of php to do it but I will try and give an overview of how to change it.

1. Create a new file in the module folder named hooks.php
2. Add this code:
Code:
class ls_reminder_events
{
    function ls_reminder_events(&$modules)
    {
        $modules->register('start', $this, 'ls_reminder_start');
    }    
}
3. Add all your functions from the original mod_user.php file just above the last closing bracket.

4. Go though each function and register it just as I have done for the ls_reminder_start function.

For example the function you posted has the name: function ls_reminder_start()

ls_reminder is the name of the module and "start" is the hook. So you want to register it to the start hook.
__________________
Eric Barnes
68 Classifieds Developer
Customer Area | Issue Tracker | Documentation | 68C Mods | 68 @ Twitter | My Modules
Eric Barnes is offline   Reply With Quote
Old 11-23-2009, 04:15 PM   #7
Customer
 
Join Date: Sep 2006
Location: USA
Posts: 156
Rep Power: 24
BigOrange will become famous soon enough
Default

I understand php and html pretty well but I don't know what other functions in the mod_user.php file you are referring to that should be added to the bottom of hooks.php. Do you mean I should ad the if statements from mod_user.php to hooks.php as well? Do I need to add something like {modulehook function="ls_reminder_start" options=""} to my home.tpl to call the function? I'm confused because I don't really know what I'm trying to do.

If I could get the following to work in home.tpl it is really all I need. However the variable: $entry.oStatus must not be available in home.tpl because it doe not return a value.

Code:
{if $entry.oStatus==3 || $entry.oStatus==4}
     My message to user about incomplete listing
{/if}

Thanks for taking the time to help me.



Quote:
Originally Posted by Eric Barnes
You will need to know the basics of php to do it but I will try and give an overview of how to change it.

1. Create a new file in the module folder named hooks.php
2. Add this code:
Code:
class ls_reminder_events
{
    function ls_reminder_events(&$modules)
    {
        $modules->register('start', $this, 'ls_reminder_start');
    }    
}
3. Add all your functions from the original mod_user.php file just above the last closing bracket.

4. Go though each function and register it just as I have done for the ls_reminder_start function.

For example the function you posted has the name: function ls_reminder_start()

ls_reminder is the name of the module and "start" is the hook. So you want to register it to the start hook.
__________________
v4.1.9 Designer - Default template (modified)

"I have never forgotten anything... if I have I can't remember what it was."

Last edited by BigOrange; 11-23-2009 at 04:39 PM.
BigOrange is offline   Reply With Quote
Old 11-23-2009, 04:46 PM   #8
68 Classifieds Staff
 
Eric Barnes's Avatar
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,489
Rep Power: 135
Eric Barnes is just really nice Eric Barnes is just really nice
Default

Let me try again. The function you posted above is named "ls_reminder_start". In previous versions this should be inside a file named mod_user.php. Now this needs to go in hooks.php in the same folder as mod_user.php.

Next the actual function name tells the script what to do. If you break the function name out "ls_reminder" is the name of the module and "start" is the name of the hook it uses. Think of it as module_name_hook()

Now in v4.1.x we use a hooks class file and have you register functions to it. So the class is named the same as the module:
PHP Code:
class ls_reminder 
Then you create a constructor to register your hooks:
PHP Code:
class ls_reminder {
    function 
ls_reminder(&$modules)
    {
        
$modules->register('start'$this'ls_reminder_start');
        
// 'start' is the hook. 'ls_reminder_start' is the function below.
    
}

    function 
ls_reminder_start()
    {
        
//original code from the very post of this thread
    
}

__________________
Eric Barnes
68 Classifieds Developer
Customer Area | Issue Tracker | Documentation | 68C Mods | 68 @ Twitter | My Modules
Eric Barnes is offline   Reply With Quote
Old 11-23-2009, 05:26 PM   #9
Customer
 
Join Date: Sep 2006
Location: USA
Posts: 156
Rep Power: 24
BigOrange will become famous soon enough
Default

I tried to do as you suggested. Below is the resulting code I'm using now.

In the /modules folder I have a folder named ls_reminder. Inside that folder is the original mod_user.php file, the original config.php file and the new hooks.php file.

Here is the hooks.php code:
Code:
<?php
class ls_reminder {
    function ls_reminder(&$modules)
    {
        $modules->register('start', $this, 'ls_reminder_start');
        // 'start' is the hook. 'ls_reminder_start' is the function below.
    }
    function ls_reminder_start()
    {
      if(($uid = (int)$_SESSION['uid']) == 0) return;
	global $db, $class_tpl;
  $reminderSQL = "SELECT display FROM ".PREFIX."listings WHERE owner = ".$uid;
  $reminderResult=$db->query($reminderSQL);
  $rows=$reminderResult->size();
	for($i=1; $i<=$rows; $i++) { // loop through this user's listings
		$rs = $reminderResult->fetch();
		if ($rs['display'] == "C") { // do they have any "Not Completed" listings?
			$class_tpl->assign('reminder_display_not_completed', TRUE);
		}
		elseif($rs['display'] == "N") { // do they have any "Not Active" listings?
			$class_tpl->assign('reminder_display_not_active', TRUE);
		}
		elseif($rs['display'] == "E") { // do they have any "Expired" listings?
			$class_tpl->assign('reminder_display_expired', TRUE);
		}
	}  // for
    }
}  
?>
Here is the code in home.tpl that I use to display the incomplete listing message that worked in v3.1.
Code:
<!-- Begin Listing Status Reminder -->
      {if $reminder_display_not_completed}
<center>Attention: One or more of your ads was not successfully completed.
<a href="userbrowselistings.php"><br><b>Click here to complete your ad.</b> </a></center>
      {/if}
<!-- END Listing Status Reminder -->
Can you see where I have a problem that keeps the if statement form displaying the reminder message when userbrowselistings.php indicates there is an incomplete listing waiting for payment?

Thanks again.
__________________
v4.1.9 Designer - Default template (modified)

"I have never forgotten anything... if I have I can't remember what it was."
BigOrange is offline   Reply With Quote
Old 11-23-2009, 07:38 PM   #10
68 Classifieds Staff
 
Eric Barnes's Avatar
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,489
Rep Power: 135
Eric Barnes is just really nice Eric Barnes is just really nice
Default

Right above this line:
if ($rs['display'] == "C") { // do they have any "Not Completed" listings?

add:

echo 'Status: '. $rs['display'].'<br />';

Then visit the home page and see what actual status is being pulled out. They may have changed.
__________________
Eric Barnes
68 Classifieds Developer
Customer Area | Issue Tracker | Documentation | 68C Mods | 68 @ Twitter | My Modules
Eric Barnes is offline   Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
how do I view/change reminder email tonystock Technical Support 16 08-08-2009 09:18 AM
Listing Renewal Reminder Confusing? manilaboy Technical Support 2 05-06-2008 03:59 PM


All times are GMT -4. The time now is 04:31 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2011, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0