Support Forums

Old 04-24-2006, 01:16 PM   #1
Senior Member
 
garysmith's Avatar
 
Join Date: Mar 2006
Location: Jackson, Mississippi
Posts: 130
Rep Power: 14
garysmith is on a distinguished road
Default Ads Listed By State

Question:

Is there a way to have a listing of the states and then show # of ads posted to that state? Maybe show this list on the side nav bar...?

Example:

Alabama (23)
Arkansas (12)
Mississippi(39)


And further if I clicked on the state it would take me to the ads posted in the respective state listed?

Is that "hard work" for a mod?

gsmith
__________________
As a Man Think-ith, So is He.
www.zFreeAds.com
www.ms-fsbo.com
garysmith is offline  
Old 04-24-2006, 05:11 PM   #2
68 Classifieds Staff
 
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 4,436
Rep Power: 101
Eric Barnes is a jewel in the rough
Default

I haven't fully tested this but I think it will work.

First create a new file named function.statesearch.php and include this:
PHP Code:
<?php
/**************************************************  *********************
| 68 Classifieds developed by 68 Designs, LLC.
|-----------------------------------------------------------------------
| All source code & content (c) Copyright 2005, 68 Designs LLC
|   unless specifically noted otherwise.
|
|The contents of this file are protect under law as the intellectual property
| of 68 Designs, LLC. Any use, reproduction, disclosure or copying
| of any kind without the express and written permission of 68 Designs, LLC is forbidden.
|
| Author $Author: Eric $ (68 Classifieds)
| Version $Revision: 1.1 $
| Updated: $Date: 2006/03/14 16:08:04 $
| __________________________________________________  ____________________
|    http://www.68classifieds.com      http://www.68designs.com/
**************************************************  *********************/
function smarty_function_statesearch($params, &$smarty)
{
    global 
$db;
     
    
//first get the states
    
$sSQL="SELECT DISTINCT `state` FROM ".PREFIX."users WHERE state <>''";
    
$result=$db->query($sSQL);
    while(
$row=$result->fetch())
    {
        
$total=0;
        
$sSQL="SELECT id FROM users WHERE state='".$row['state']."'";
        
$result=$db->query($sSQL);
        while(
$rs=$result->fetch())
        {
            
$sSQL="SELECT COUNT(*) AS total FROM products WHERE owner=".$rs['id'];
            
$result=$db->query($sSQL);
            
$state=$result->fetch();
            
$total+=$state;
        }
        
$output.='<option value="'.$row['state'].'">'.$row['state'].' ('$total .')</option>';
    }
    return 
$output;
}
?>
Next upload it to the includes/template/plugins directory.

Finally open your template file search.tpl.php and locate this:
{section name=i loop=$states}
<option value="{$states[i].state}">{$states[i].state}</option>
{/section}

Replace it with:
{stateseach}
__________________
Eric Barnes
68 Classifieds Developer
Please do not send me a private message asking for support. Instead use these open forums or our ticket system.

Customer Area | Issue Tracker | Documentation | 68C Mods | Submit a Ticket | Twitter
Eric Barnes is offline  
Old 04-24-2006, 08:42 PM   #3
Senior Member
 
garysmith's Avatar
 
Join Date: Mar 2006
Location: Jackson, Mississippi
Posts: 130
Rep Power: 14
garysmith is on a distinguished road
Default

Quote:
Finally open your template file search.tpl.php and locate this:
{section name=i loop=$states}
<option value="{$states[i].state}">{$states[i].state}</option>
{/section}

Replace it with:
{stateseach}
Eric...followed everything up to here...

do i replace all the red with the blue?

gsmith
__________________
As a Man Think-ith, So is He.
www.zFreeAds.com
www.ms-fsbo.com
garysmith is offline  
Old 04-24-2006, 09:19 PM   #4
68 Classifieds Staff
 
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 4,436
Rep Power: 101
Eric Barnes is a jewel in the rough
Default

Yes that is correct.
__________________
Eric Barnes
68 Classifieds Developer
Please do not send me a private message asking for support. Instead use these open forums or our ticket system.

Customer Area | Issue Tracker | Documentation | 68C Mods | Submit a Ticket | Twitter
Eric Barnes is offline  
Old 04-24-2006, 09:43 PM   #5
Senior Member
 
garysmith's Avatar
 
Join Date: Mar 2006
Location: Jackson, Mississippi
Posts: 130
Rep Power: 14
garysmith is on a distinguished road
Default

I don't think it recognized the tag?

I clicked search and got this:

Quote:
Fatal error: Smarty error: [in search.tpl.php line 91]: syntax error: unrecognized tag 'stateseach' (Smarty_Compiler.class.php, line 580) in /home/zfreeads/public_html/includes/template/Smarty.class.php on line 1095
__________________
As a Man Think-ith, So is He.
www.zFreeAds.com
www.ms-fsbo.com
garysmith is offline  
Old 04-24-2006, 09:50 PM   #6
68 Classifieds Staff
 
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 4,436
Rep Power: 101
Eric Barnes is a jewel in the rough
Default

Sorry I spelled it wrong.
It should be: {statesearch}
__________________
Eric Barnes
68 Classifieds Developer
Please do not send me a private message asking for support. Instead use these open forums or our ticket system.

Customer Area | Issue Tracker | Documentation | 68C Mods | Submit a Ticket | Twitter
Eric Barnes is offline  
Old 04-24-2006, 10:19 PM   #7
Senior Member
 
garysmith's Avatar
 
Join Date: Mar 2006
Location: Jackson, Mississippi
Posts: 130
Rep Power: 14
garysmith is on a distinguished road
Default

almost there...

now the pull down in the state area comes up and only one state is there...and announces like this: Mississippi 0 . Go to www.zfreeads.com and do a "search ads" at the top nav bar...then click state.

I have about 8-10 states with data in the system.

Only one shows in the pull down menu at search.

gsmith
__________________
As a Man Think-ith, So is He.
www.zFreeAds.com
www.ms-fsbo.com
garysmith is offline  
Old 04-24-2006, 10:35 PM   #8
68 Classifieds Staff
 
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 4,436
Rep Power: 101
Eric Barnes is a jewel in the rough
Default

Will you change it back for now and I will do some testing and give you some new code to use. I think it has to do with the way I am looping through the results.
__________________
Eric Barnes
68 Classifieds Developer
Please do not send me a private message asking for support. Instead use these open forums or our ticket system.

Customer Area | Issue Tracker | Documentation | 68C Mods | Submit a Ticket | Twitter
Eric Barnes is offline  
Old 04-24-2006, 10:38 PM   #9
Senior Member
 
garysmith's Avatar
 
Join Date: Mar 2006
Location: Jackson, Mississippi
Posts: 130
Rep Power: 14
garysmith is on a distinguished road
Default

Yes Sir!

Done.

gsmith
__________________
As a Man Think-ith, So is He.
www.zFreeAds.com
www.ms-fsbo.com
garysmith is offline  
Old 04-25-2006, 01:25 PM   #10
68 Classifieds Staff
 
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 4,436
Rep Power: 101
Eric Barnes is a jewel in the rough
Default

Ok Gary,

Try this.
Change all the code in that function.statesearch file with the following then upload and change the template back.

PHP Code:
<?php
/**************************************************  *********************
| 68 Classifieds developed by 68 Designs, LLC.
|-----------------------------------------------------------------------
| All source code & content (c) Copyright 2005, 68 Designs LLC
|   unless specifically noted otherwise.
|
|The contents of this file are protect under law as the intellectual property
| of 68 Designs, LLC. Any use, reproduction, disclosure or copying
| of any kind without the express and written permission of 68 Designs, LLC is forbidden.
|
| Author $Author: Eric $ (68 Classifieds)
| Version $Revision: 1.1 $
| Updated: $Date: 2006/03/14 16:08:04 $
| __________________________________________________  ____________________
|    http://www.68classifieds.com      http://www.68designs.com/
**************************************************  *********************/
function smarty_function_statesearch($params, &$smarty)
{
    global 
$db;
     
    
//first get the states
    
$sSQL="SELECT DISTINCT `state` FROM ".PREFIX."users WHERE state <>''";
    
$result=$db->query($sSQL);
    while(
$row=$result->fetch())
    {
        
$total=0;
        
$sSQL="SELECT id FROM ".PREFIX."users WHERE state='".$row['state']."'";
        
$result2=$db->query($sSQL);
        while(
$rs=$result2->fetch())
        {
            
$sSQL="SELECT COUNT(*) AS total FROM ".PREFIX."products WHERE owner=".$rs['id'];
            
$result3=$db->query($sSQL);
            
$state=$result3->fetch();
            
$total=$state['total']+$total;
        }
        
$output.='<option value="'.$row['state'].'">'.$row['state'].' ('$total .')</option>';
    }
    return 
$output;
}
?>
__________________
Eric Barnes
68 Classifieds Developer
Please do not send me a private message asking for support. Instead use these open forums or our ticket system.

Customer Area | Issue Tracker | Documentation | 68C Mods | Submit a Ticket | Twitter
Eric Barnes is offline  
 

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Don't want State, Country to display dawnrae v3.1 Questions & Support 2 01-19-2007 12:44 PM
Selecting a default State manilaboy v3.1 Questions & Support 2 10-17-2006 01:40 PM
State (Non AU) Chaslie v3.1 Questions & Support 2 05-26-2006 09:49 AM
Changing State to County sporthorsebreeder v3.1 Questions & Support 2 05-23-2006 05:05 AM
State field quickbiz v3.0 Questions & Support 6 04-25-2006 01:03 PM


All times are GMT -4. The time now is 07:03 AM.


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