 |

Deven
User
Feb 28, 2005, 8:56 AM
Post #1 of 50
(28565 views)
Shortcut
|
Random Listings Script
|
Can't Post
|
|
This script will randomly display a listing on your site via SSI. To use this script you must have a server that supports PHP and Listing Manager version 2.28 or above. The default template used is the _publish_listing.html template. Note that if you specify another template, it must define all the templatecells found in the _publish_listing.html template. Step 1- Edit the variables in the script. Step 2- Upload the script to the same directory that your page contains the SSI is in. Step 3- Add your SSI to your page to call this file, example: <!--#include file="random.php" --> Note that I've only tested this script on a Linux server. Please post questions or bugs in this forum. ~~~Deven
(This post was edited by Deven on Feb 28, 2005, 8:58 AM)
|
|
Attachments:
|
random.php
(1.46 KB)
|
|
|  |
 |

ross
Staff
/ Moderator

Feb 28, 2005, 11:25 AM
Post #2 of 50
(28548 views)
Shortcut
|
|
Re: [Deven] Random Listings Script
[In reply to]
|
Can't Post
|
|
Hi Devon. Thanks for posting! This sounds like a really cool script. I don’t actually have a PHP server to test this out on in the office though. If anyone in the community was interested in testing out, perhaps we could get you to post up your success stories for everyone else to see. If you have anymore great addon scripts don’t hesitate to post them up either. We are always glad to see new ways of extending our software . ----------------------------------------------------------- Cheers, Ross Fairbairn - Product Specialist support@interactivetools.com
Hire me! Save time by getting our experts to help with your project. Template changes, advanced features, full integration, whatever you need. Whether you need one hour or fifty, get it done fast with Priority Consulting.
|
|
|  |
 |

Deven
User
Feb 28, 2005, 12:50 PM
Post #3 of 50
(28544 views)
Shortcut
|
|
Re: [ross] Random Listings Script
[In reply to]
|
Can't Post
|
|
What's really cool about this script is your pages don't have to be PHP, in other words ending with the .php extension. Of course you do need PHP installed on the server in order to parse the script. You just upload the random.php script to your server, then stick this one little snippet of code in your .shtml page: <!--#include file="random.php" --> You can see an example here. Refresh the page and you'll get a different listing result. http://www.westteaysrealty.com/test.shtml . All I did was create an .shtml page and inserted the above code snippet. Just edit your template how you want it and you can have a new property listing, new car listing, whatever is in your database. Enjoy. Anyone who trys this script, would you please let me know your experiences so others may know? Thanks again.....Deven
(This post was edited by Deven on Feb 28, 2005, 1:47 PM)
|
|
|  |
 |

bobdob
User
Apr 27, 2005, 11:19 PM
Post #4 of 50
(28383 views)
Shortcut
|
|
Re: [Deven] Random Listings Script
[In reply to]
|
Can't Post
|
|
where can I get my hands on this php scritp? am I missing somthing?
|
|
|  |
 |

bobdob
User
Apr 28, 2005, 12:31 AM
Post #6 of 50
(28380 views)
Shortcut
|
|
Re: [OtownAutos] Random Listings Script
[In reply to]
|
Can't Post
|
|
ohh...yeah there it is. please forgive me I am running in half conscious mode and blue on blue is no good. thanks!
|
|
|  |
 |

jasper
User
Apr 30, 2005, 4:06 PM
Post #7 of 50
(28349 views)
Shortcut
|
|
Re: [Deven] Random Listings Script
[In reply to]
|
Can't Post
|
|
Hi Deven, I follow your instructions but I can't do it, I receive this message: Fatal error: Call to undefined function: virtual() /home/juna/www/www/random.php on line 47 and this is line 47: virtual($search."?view=$listing_num[0]&template=".$template); Do you have any idea where the problem is? Thankyou!
|
|
|  |
 |

Deven
User
Apr 30, 2005, 6:48 PM
Post #8 of 50
(28346 views)
Shortcut
|
|
Re: [jasper] Random Listings Script
[In reply to]
|
Can't Post
|
|
Check your path. It looks like you have www in there twice. Not sure if that's your correct path.
|
|
|  |
 |

jasper
User
May 1, 2005, 5:18 AM
Post #9 of 50
(28335 views)
Shortcut
|
|
Re: [Deven] Random Listings Script
[In reply to]
|
Can't Post
|
|
It is the correct path, is with /www/ twice...???
|
|
|  |
 |

Deven
User
May 1, 2005, 6:04 PM
Post #10 of 50
(28300 views)
Shortcut
|
|
Re: [jasper] Random Listings Script
[In reply to]
|
Can't Post
|
|
It may be the way your server handles PHP virtual(). virtual() is an Apache-specific function which is equivalent to <!--#include virtual...--> in mod_include. This function works only when PHP is compiled as an Apache module, since it uses the Apache API for doing sub requests. You may want to try this: Comment out line 47 by adding 2 forward slashes in front of it ( i.e.... // ). Then on the next line down add this: echo $listing_num[0]; You should see a different listing number each time you reload the page. If this works ok, then can build the whole thing right in this script. Here's an example of the whole script: <?php //Path to listing.dat.cgi file. $path = "cgi-bin/listman/data/listing.dat.cgi"; //Put listings into an array. $array = file($path); //Remove first 3 lines of listing.dat file. array_splice($array,0,3); //Randomize the array. $element = $array[rand(0, count($array)-1)]; //Separate each field. $listing_num = explode("¡", $element); //Strip everything past the 75th field. array_splice($listing_num, 75); //If no image, let's use a default one. if ($listing_num[4] == ''){ $listing_num[4] = ('nophoto.jpg'); } else { $listing_num[4] = $listing_num[4]; } ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>Random Listing</title> </head> <body> <table border="0" cellpadding="0" style="border-collapse: collapse" width="150" id="table1" bgcolor="#000080"> <tr> <td> <p align="center"><font color="#FFFFFF"><b>Random Listing</b></font></td> </tr> </table> <table border="1" width="150" bordercolor="#003366" bgcolor="#DFDFDF"> <tr> <td> <p align="center"><br><a href="http://yourdomain.com/cgi-bin/listman/exec/search.cgi?view=<?php echo $listing_num[0];?>"><img src="http://yourdomain.com/listman/listings/images/<?php echo $listing_num[4];?>" border="0" width="140"></a></p> <font face="Trebuchet MS" size="2" color="#800000"> <?php echo $listing_num[14];?><br> <?php echo $listing_num[16]." ".$listing_num[17];?><br> <?php echo $listing_num[19];?><br> <a href="http://yourdomain.com/cgi-bin/listman/exec/search.cgi?view=<?php echo $listing_num[0];?>">details...</a><br></font> </td> </tr> </table> <table border="1" cellpadding="0" style="border-collapse: collapse" width="150" id="table3" bgcolor="#000080"> <tr> <td> </td> </tr> </table> <br> </body> </html> Now you'll see from above I looked in my listing.dat.cgi file and examined each field to see what it represents. Starting with the first field $listing_num[0] is my listing number, followed by the separator "¡", then my second field would be $listing_num[1], 3rd field would be $listing_num[2], and so on... Also I have an if,else statement in this script that says if no image is found, use an image which i created and uploaded to my \listman\listings\images folder. It's a jpg image that says "No photo available". You can insert each field you want to display using this: <?php echo $listing_num[x];?> "x" represents the field position of the item to display. After your done, make sure this file's name ends with the .php extention. Then you can use a include statement in your .shtml page to include this php page. Example: <!--#include file="random.php" --> Hope this helps everyone who wants a random listing to display perhaps on their home page. ~~~Deven
(This post was edited by Deven on May 1, 2005, 7:09 PM)
|
|
|  |
 |

jasper
User
May 2, 2005, 4:44 AM
Post #11 of 50
(28285 views)
Shortcut
|
|
Re: [Deven] Random Listings Script
[In reply to]
|
Can't Post
|
|
Thanks a lot Deven, now is working!
|
|
|  |
 |

maher
User
May 18, 2005, 5:39 PM
Post #12 of 50
(27978 views)
Shortcut
|
|
Re: [Deven] Random Listings Script
[In reply to]
|
Can't Post
|
|
Great add on, I try it and it works perfectly, but if I need it to randomly retrieve only a summary of a listing, not the complete details of the listing, what do I have to do? Thanx
|
|
|  |
 |

Deven
User
May 18, 2005, 7:33 PM
Post #13 of 50
(27973 views)
Shortcut
|
|
Re: [maher] Random Listings Script
[In reply to]
|
Can't Post
|
|
Examine your listing.dat.cgi file, then starting from the left the first entry will count from zero [0], find the field that contains your summary text and then display it like this: <?php echo $listing_num[20];?> (this is assuming your summary text is located in the 20th position.) Let me know if this makes sense. Deven
|
|
|  |
 |

croydon
User
Jun 20, 2005, 8:42 PM
Post #14 of 50
(27687 views)
Shortcut
|
|
Re: [Deven] Random Listings Script
[In reply to]
|
Can't Post
|
|
Hi Deven, I'm trying to get your script working but it refuses to. Obviously I am doing something wrong. I want the random listing to show on www.housetobuy.co.nz/index.shtml Both index.shtml & random.php are loaded into the htdocs folder. I have not altered your script at all. Do I need to alter anything were you say "//**************** Edit These Variables ******************* // Path to listing.dat.cgi $path = "cgi-bin/listman/data/listing.dat.cgi"; //Path to search.cgi $search = "cgi-bin/listman/exec/search.cgi"; //Template name. We're using _publish_listing.html for an example. $template = "_publish_listing.html";" as I have not altered any paths from the origional instalation 2.52? Firefox gives the following error mesage " Warning: file(cgi-bin/listman/data/listing.dat.cgi): failed to open stream: No such file or directory in /var/users/akaroa/housetobuy.co.nz/htdocs/random.php on line 32 Warning: array_splice(): The first argument should be an array in /var/users/akaroa/housetobuy.co.nz/htdocs/random.php on line 35 " Excuse my ignorance but I am new to working with .php Cheers Croydon
(This post was edited by croydon on Jun 20, 2005, 8:47 PM)
|
|
|  |
 |

Deven
User
Jun 21, 2005, 4:02 AM
Post #15 of 50
(27683 views)
Shortcut
|
|
Re: [croydon] Random Listings Script
[In reply to]
|
Can't Post
|
|
It is the path (cgi-bin/listman/data/listing.dat.cgi) that the script is complaining about. Try (../cgi-bin/listman/data/listing.dat.cgi) or a few different variations. Work on the path statement. You can test the script just by loading the php page....i.e.- http://www.housetobuy.co.nz/random.php. If you are still having trouble, look at post#10 above. You can copy the code and see if it works by itself. The array_splice warning will go away once this first problem is addressed. Croydon, When you fix this, please post your solution for others. Deven.
(This post was edited by Deven on Jun 21, 2005, 4:13 AM)
|
|
|  |
 |

dmonsour
User
Nov 30, 2005, 10:39 AM
Post #16 of 50
(25737 views)
Shortcut
|
|
Re: [Deven] Random Listings Script
[In reply to]
|
Can't Post
|
|
Deven. Great script! It works quite well. Couple of questions for you or anyone else who knows more about this... 1. I would like to pull and display more than one listing... preferably two. 2 . I would also like to only pull listings that have a specific criteria in a field... Such as only those marked as featured. So it would look first through all listings, only pull those with 'Featured Listing' marked in field 22 and then randomize those for output. Right now I use SSI to display 2 listings on pages. It uses a search criteria to identify only those marked as featured. So basically I would like to keep this functionality only randomize the output so that when there are more than 2, the same ones do not always display. Thanks for any help anyone may be able to provide.
(This post was edited by dmonsour on Nov 30, 2005, 12:38 PM)
|
|
|  |
 |

dmonsour
User
Dec 6, 2005, 9:32 PM
Post #17 of 50
(25665 views)
Shortcut
|
|
Re: [dmonsour] Random Listings Script
[In reply to]
|
Can't Post
|
|
Anyone? Bueller? Bueller?
|
|
|  |
 |

ross
Staff
/ Moderator

Dec 7, 2005, 2:23 PM
Post #18 of 50
(25641 views)
Shortcut
|
|
Re: [dmonsour] Random Listings Script
[In reply to]
|
Can't Post
|
|
Hi there. Thanks for posting! Since Deven created this script in the first place, I am not going to be that much help with modifying it. I think the best thing would be to try private messaging Deven to see if she can offer any additional help. You’ll need to keep in mind that she might have other projects on the go but I am sure as soon as she has time she will bet back to you. Keeps us up to date on how you are making out . ----------------------------------------------------------- Cheers, Ross Fairbairn - Product Specialist support@interactivetools.com
Hire me! Save time by getting our experts to help with your project. Template changes, advanced features, full integration, whatever you need. Whether you need one hour or fifty, get it done fast with Priority Consulting.
|
|
|  |
 |

drodrig
User
Jan 27, 2006, 6:06 AM
Post #19 of 50
(25220 views)
Shortcut
|
|
Re: [dmonsour] Random Listings Script
[In reply to]
|
Can't Post
|
|
Hi! I am wondering if anyone has figured out a way to display multiple listings randomly?
|
|
|  |
 |

drodrig
User
Mar 2, 2006, 9:40 AM
Post #21 of 50
(24899 views)
Shortcut
|
|
Re: [mbodamer] Random Listings Script
[In reply to]
|
Can't Post
|
|
Thank you for that suggestion. What you mentioned would probably work, but the site in question is relatively busy and I believe that the multiple calls to the php script would cost too much in terms of resources.
|
|
|  |
 |

Deven
User
Mar 8, 2006, 5:20 AM
Post #22 of 50
(24790 views)
Shortcut
|
|
Re: [drodrig] Random Listings Script
[In reply to]
|
Can't Post
|
|
It's been quite a while since I wrote this script. To display a second listing you might try this: Right after this line: virtual($search."?view=$listing_num[0]&template=".$template); Add a new line: virtual($search."?view=$listing_num[1]&template=".$template); You can see I'm just calling the next listing in the randomized array. Let me know if this works. I currently don't have a site to test this on. ~~~Deven
|
|
|  |
 |

drodrig
User
Mar 8, 2006, 5:39 AM
Post #23 of 50
(24787 views)
Shortcut
|
|
Re: [Deven] Random Listings Script
[In reply to]
|
Can't Post
|
|
Thank you. I will give it a try.
|
|
|  |
 |

gspinney
New User
Mar 12, 2006, 1:49 AM
Post #24 of 50
(24693 views)
Shortcut
|
|
Re: [croydon] Random Listings Script
[In reply to]
|
Can't Post
|
|
I use the random.php script on my site, with a few hacks so it pulls 4 unique listing at once. Never pulls a duplicate. www.bchomes.ca email me if you need help getting your script to work kiwi.
|
|
|  |
 |

cclinton
User
Mar 22, 2006, 6:36 PM
Post #25 of 50
(24408 views)
Shortcut
|
|
Re: [Deven] Random Listings Script
[In reply to]
|
Can't Post
|
|
I am trying and not having luck with this script. I ran into the problem with line 47, ran the test and got random numbers. Thus I rewrote the code as instructed in post #10, modified the links and src's so that they point to the correct page and it doesn't work. The nicely laid out chart shows up but it pulls no image, pulls no information. Plus, when I click on the links, it opens the search query template. I have even attempted to change chmod permissions without any luck. Any ideas? I attached my file for reference.
|
|
Attachments:
|
random3.php
(2.07 KB)
|
|
|  |
|