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 } ?>
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 -->
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.
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.
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.
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: class ls_reminder Then you create a constructor to register your hooks: 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() { //original code from the very post of this thread }}
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.
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.
After adding the code in the location you suggested I see nothing different on the home page. However, if I insert the echo statement just after the opening <php tag at the top of hooks.php I see, "Status:" displayed on the home page. That is the only place in the code where I can insert the echo statement that will display anything on the home page. The module is being called but it seems the function is not executed for some reason. Below is what I added to the home page to call the module. I'm not sure if it is correct. {modulehook function="ls_reminder_start" options=""}
Could somebody please give this another shot at getting it working. I would really like to use it on my new site. I have tried and tried and can't figure out how to do it. Any help is appreciated.