Main
Index
Search
Posts
Who's
Online
Log
In

Home: Discontinued/Classic Products: Listings Manager (Realty Manager & Auto Manager):
Invoking A Custom Template From A Search Form

 

 


david259
New User

Feb 13, 2009, 11:10 PM

Post #1 of 3 (2700 views)
Shortcut
Invoking A Custom Template From A Search Form Can't Post

Hello!

My client (a large real estate agency) is an enthusiastic user of Realty Manager. They have hundreds of listings for Homes, Land, Farms, Acreage, Commercial and Auction properties - and while the basic templates suit them just fine for most of these categories, they want to implement a separate template for their Commercial listings.

Following some instructions I found in another post on this board, I was able to create separate _search_results_comm.html and _publish_listing_comm.html templates and get them them to come up correctly on all the direct links in their site, so I have no problem with that (eg: <A HREF="..blahblah...">List All Commercial Properties</A>

But my client *also* has a search box that allows visitors to query all the listings on the site. And I'm at a loss how to instruct search.cgi to use the normal templates for all categories except "Commercial" (ie if a client selects "Commercial" as a type in the search box, which is "lfield3_keyword" on his particular search box set-up)

I keep thinking that I may need an IF...ELSE statement - perhaps in Javascript - to the effect that IF lfield3_keyword=Commercial (call the Commercial template) ELSE (call the normal templates) ENDIF when invoking search.cgi, But I have no idea how to do this, and I'm sure you probably know an easier way anyway.

Can you offer any advice? Thanks in advance! Smile


(This post was edited by david259 on Feb 14, 2009, 5:23 PM)


MikeB
Staff / Moderator


Feb 16, 2009, 5:46 PM

Post #2 of 3 (2644 views)
Shortcut
Re: [david259] Invoking A Custom Template From A Search Form [In reply to] Can't Post

Hi David,

Thanks for posting!

Listings Manager will use it's default template to publish all of the static HTML listing pages. That said, you're able to set up the results template so it will point to your Commercial listings using the search engine and your custom template.

To do this you'll just modify your _search_results.html template and add some conditional JavaScript as you had suspected. Once you've made a backup of this file you'll just find any links that look like this:

<a href="$listing_url$/$listing_file$">

And replace them with this JavaScript:


Code
<script type="text/javascript">  
if ('$lfield3$'=='Commercial')
{
document.write('<a href="$search_url$?view=$listing_num$&template=_publish_listing_comm.html">');
}
else
{
document.write('<a href="$listing_url$/$listing_file$">');
}
</script>



This should then ensure that any listing that is set to "Commercial" for lfield3, will use a different URL and therefore a different template.

I hope this helps! Smile

Cheers,
Mike Briggs - Product Specialist
support@interactivetools.com

[hr][i][url "http://www.interactivetools.com/consulting/"][b]Hire me![/b][/url]
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 [url "http://www.interactivetools.com/consulting/"][b]Priority Consulting[/b][/url].[/i]


david259
New User

Feb 16, 2009, 6:34 PM

Post #3 of 3 (2642 views)
Shortcut
Re: [MikeB] Invoking A Custom Template From A Search Form [In reply to] Can't Post

Mike - I want to have your child!

This is a brilliant (and quite simple) solution and I had it up and running in 5 minutes. Works like a charm - thankyou so much.

Cheers! Smile

PS: Could I suggest that you put this post and the earlier one about how to effect the same result on hyperlinks into a tutorial somewhere (or even the online manual?).

These two posts are simpler and clearer than what's in the manual right now and I think they'd answer many people's questions in this area. In addition, putting them in the online manual would also save you guys having to answer this question again in the future.

Thanks again!


(This post was edited by david259 on Feb 16, 2009, 6:35 PM)