 | |  |
 |

fstrat94
Novice
Aug 1, 2005, 2:15 PM
Post #1 of 18
(9646 views)
Shortcut
|
|
Issues with including php scripts in templates
|
Can't Post
|
|
Hi. I'm having some trouble including php scripts that I've written in the templates. When the listings/homepages get published, two lines get added to the top of each listing/homepage: a comment line (last modified date) and an empty line right below it. This screws with my php code that tries to set headers and cookies because those top two lines get sent to the browser before my headers can get set. I end up getting "headers already sent" errors. Is there any way to remove those two lines from all generated pages? Here's an example of what happens: in my template (_publish_homepage.html) I have something like: <? include ("stuff.php"); if (!$session->logged_in) { header("Location: http://some.place.net") } else { ?> <html> <body> stuff </body> </html> <? } ?> the published homepages (h0001.php) end up with: <!-- Last Updated Mon Aug 1 16:55:12 2005 --> <? include ("stuff.php"); if (!$session->logged_in) { header("Location: http://some.place.net") } else { ?> <html> <body> stuff </body> </html> <? } ?> Because that comment line and new line come before my code to set the header, I get a "headers already sent" error. Any ideas?
|
|
|  |
 |

ross
Staff
/ Moderator

Aug 1, 2005, 4:19 PM
Post #2 of 18
(9641 views)
Shortcut
|
|
Re: [fstrat94] Issues with including php scripts in templates
[In reply to]
|
Can't Post
|
|
Hi fstrat. Thanks for posting and welcome to the board! You can tell Listings Manager to not publish that date stamp to your listings using the following steps: 1. Log into Listings Manager and go to Setup Options -> General tab. 2. Scroll down until you see “Add meta generator tag?”. 3. Switch this to no. 4. Hit Save. 5. Hit all 4 Publish buttons And that’s it. Could you give this a try and let me know how you make out? I look forward to hearing from you . ----------------------------------------------------------- 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.
|
|
|  |
 |

fstrat94
Novice
Aug 1, 2005, 5:04 PM
Post #3 of 18
(9639 views)
Shortcut
|
|
Re: [ross] Issues with including php scripts in templates
[In reply to]
|
Can't Post
|
|
Thanks. That did it. Now to figure out how to get this to work in the search pages. It seems that there's no way to get php includes to work by including them in the search templates. Any suggestions (besides iframes)?
|
|
|  |
 |

MikeB
Staff
/ Moderator

Aug 2, 2005, 2:40 PM
Post #4 of 18
(9618 views)
Shortcut
|
|
Re: [fstrat94] Issues with including php scripts in templates
[In reply to]
|
Can't Post
|
|
Hi, Thanks for the post! I'm glad to hear you were able to get the includes working on your Listings Manager pages. As Listings Manager's search query and search results page are dynamic pages you'll find that you won't actually be able to use any includes on them. To have this content show up on your search pages you'll either want to use a frame or hard code this content directly onto your search query and search result template files. I hope this helps and if you have any other questions feel free to let me know! Cheers, Mike Briggs - 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.
|
|
|  |
 |

fstrat94
Novice
Aug 2, 2005, 2:59 PM
Post #5 of 18
(9614 views)
Shortcut
|
|
Re: [MikeB] Issues with including php scripts in templates
[In reply to]
|
Can't Post
|
|
Actually, I was able to come up with a way to "wrap" the search calls into my own php pages. Once I did that, all I had to do was change all of the references to search.cgi to point to my php script instead. The wrapper page, search_query.php, contains the contents of _search_query.html template but submits it's form to another php page, search_results.php. search_results.php then calls the search.cgi and inserts the contents into its own output like this:
<? $cgipath = "http://domain.name/path/to/search.cgi?"; foreach ($_GET as $key => $val) { $cgipath = $cgipath.$key."=".urlencode($val)."&"; } $cgiOutput = file_get_contents($cgipath); echo $cgiOutput; ?> So now I'm able to do php includes in the search pages as well.
|
|
|  |
 | |  |
 |

Cliff
Staff

Aug 3, 2005, 11:56 AM
Post #7 of 18
(9596 views)
Shortcut
|
|
Re: [fstrat94] Issues with including php scripts in templates
[In reply to]
|
Can't Post
|
|
Hi fstrat94, Thanks for posting. I second Lee's motion! I'd love to see that in action, feel free to send me a Private Message if you prefer that to posting in the forum Regards, Cliff Stefanuk - Customer Service Manager support@interactivetools.com
|
|
|  |
 |

fstrat94
Novice
Aug 3, 2005, 1:24 PM
Post #8 of 18
(9589 views)
Shortcut
|
|
Re: [Cliff] Issues with including php scripts in templates
[In reply to]
|
Can't Post
|
|
Sorry, I can't post a link to a live site because it's still in heavy development on my personal server. Cliff, I'm sending you a private message.
|
|
|  |
 | |  |
 |

fstrat94
Novice
Aug 4, 2005, 7:00 AM
Post #10 of 18
(9557 views)
Shortcut
|
|
Re: [leeshields] Issues with including php scripts in templates
[In reply to]
|
Can't Post
|
|
I've actually improved the search wrapper a bit more since I wrote the message. Basically there's one search.php that wraps calls to search.cgi and includes the result in its own html. You'll have to change the "Search Engine URL" configuration to point to the search.php. In the _search_query.html template, you have to change the form action to use $search_url$ instead of $cgiurl$. Then you just have to creatively write the html in the search.php and the search templates so that it still looks ok. This is an example of what the search.php might look like:
<html><head> <title>Search Listings</title> <meta name="robots" content="noindex,nofollow"> </head> <BODY bgcolor="#FFFFFF" TEXT="#000000" LINK="#000066" VLINK="#000066" alink="#000066"> <center> <p> <table border=0 cellspacing=0 cellpadding=2 width=590> <tr> <td> <font face="arial,ms sans serif" size=4><b>XYZ Real Estate</b></font> <hr size=1> <div align=right> <font face="ms sans serif" size=1> <? include("navlinks.php") ?> </font><br> </div> </td> </tr> </table> <table border=0 cellspacing=0 cellpadding=0 width=580> <tr><td><font face="arial,ms sans serif" size=3><b>Search Listings</b></font></td></tr> </table> <? $cgipath = "http://".$_SERVER['HTTP_HOST']."/cgi-bin/listman/exec/search.cgi?"; foreach ($_GET as $key => $val) { $cgipath = $cgipath.$key."=".urlencode($val)."&"; } $cgiOutput = file_get_contents($cgipath); echo $cgiOutput; ?> </center> </body></html> Let me know if you have any other questions. I'm still pretty new to LM and php, but I'll help as much as I can.
|
|
|  |
 |

leeshields
User
Sep 5, 2005, 6:25 AM
Post #11 of 18
(9304 views)
Shortcut
|
|
Re: [fstrat94] Issues with including php scripts in templates
[In reply to]
|
Can't Post
|
|
Hi Have you had any problems with this script? I tried using an include of the search.cgi script in PHP pages a little while ago, and for most pages it was fine, but on certain results the content (added by the client in descriptions) would break the PHP, worked fine in an shtml include but not in a php one, I didnt really find a solution to it. Seemed certain client addable characters were breaking the script. Any thoughts? Thanks Lee __ Lee Shields Apogee Technology John R Hornsby Adelante Properties Villassist Paul Withey Estate Agents
|
|
|  |
 |

jasper
User
Mar 22, 2006, 10:19 AM
Post #12 of 18
(8313 views)
Shortcut
|
|
Re: [fstrat94] Issues with including php scripts in templates
[In reply to]
|
Can't Post
|
|
Hi fstrat94, hi all can somebody tell me if there are any way for (search.php) to use php script for parsing the url query string into the form fields, and if there are some script can you please send me one? Thanks guys!
|
|
|  |
 |

ross
Staff
/ Moderator

Mar 22, 2006, 1:12 PM
Post #13 of 18
(8304 views)
Shortcut
|
|
Re: [jasper] Issues with including php scripts in templates
[In reply to]
|
Can't Post
|
|
Hi jasper. Thanks for posting! I am not really a PHP guru but I would imagine you could parse out the query string variables. They are all passed through this placeholder: $query$ so you can try with that one. The specific code would be beyond my level of expertise, but that should at least get you going . ----------------------------------------------------------- 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.
|
|
|  |
 |

jasper
User
Mar 22, 2006, 1:25 PM
Post #14 of 18
(8302 views)
Shortcut
|
|
Re: [ross] Issues with including php scripts in templates
[In reply to]
|
Can't Post
|
|
Thanks for reply ross, I thought there is nobody in this forum any more...anyway one thing I'm scare of is even with this methond: /////////////////// <? $cgipath = "http://".$_SERVER['HTTP_HOST']."/cgi-bin/listman/exec/search.cgi?"; foreach ($_GET as $key => $val) { $cgipath = $cgipath.$key."=".urlencode($val)."&"; } $cgiOutput = file_get_contents($cgipath); echo $cgiOutput; ?> //////////////////////////// ... the search result page is still the html template where php code don't work... I try with simple php date code <?php print gmdate('d-m-y / G:i'); ?> in the search_result.html but don't work??? don't know why?
|
|
|  |
 |

ross
Staff
/ Moderator

Mar 23, 2006, 10:57 AM
Post #15 of 18
(8281 views)
Shortcut
|
|
Re: [jasper] Issues with including php scripts in templates
[In reply to]
|
Can't Post
|
|
Hi jasper. The first thing I can think of here is that because the search page is dynamically generated, so it just isn’t going to run PHP code. I know for sure that include statements aren’t going to run, but now I am thinking the same is also true for regular PHP. Like I had mentioned earlier, I am not really a PHP guru so we are beginning to leave my area of expertise. I had been reading through some of the earlier posts in this thread and it does look like fstrat94 was able to have the search script working side by side with PHP. Had you given his code a run through on your site? Perhaps you could send fstrat94 a private message to see if there are anymore options available. Keep me up to date with how you 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.
|
|
|  |
 |

BuffaloWeb
User
Apr 16, 2006, 8:01 AM
Post #16 of 18
(7930 views)
Shortcut
|
|
Re: [ross] Issues with including php scripts in templates
[In reply to]
|
Can't Post
|
|
I know php well enough, and it looks like what fstrat94 posted would work. I haven't tried it myself yet, so I'm not sure how the cgi would react in certain cases. For example, if you search and the results are across multiple pages, would clicking on a "next page" link take you outside of the php and back into the cgi-driven pages? If you changed the "next page" links to send you to php, would you need to code those links to have the php transfer "page location" to the cgi script? Hopefully I'll get a chance to experiment and let you know. I think that having a good templating system (eg, header/footer/nav includes) is crucial and often overlooked. Developing sites for clients, as I do, *should* include the developer's paying attention to future maintenance. And having to change headers and footers in multiple locations is a bad (*really* bad) idea. Hopefully the php will do the trick! FWIW, InterActiveTools might want to consider alternative approaches in future releases of all their products. It should be easy enough to have each script programmed to look for a header/footer in a specified location; if there, read and print, if not, ignore. At least it would leave the door open for proper includes, no?
|
|
|  |
 |

glav
New User
Oct 8, 2007, 5:46 PM
Post #17 of 18
(2971 views)
Shortcut
|
|
Re: [BuffaloWeb] Issues with including php scripts in templates
[In reply to]
|
Can't Post
|
|
OK - I have updated my version to latest and it works but I want it to do something I can not figure out. The search.cgi is located here. http://www.hhi.ie/cgi-bin/rm/exec/search.cgi But I call it using this URL http://www.hhi.ie/index.php?a=cgi-bin/rm/exec/search I can do this as I have a file in the exec called search.php with this piece of code. "<?php // Change $file to the full url to your MT cgi search script $file="http://www.hhi.ie/cgi-bin/rm/exec/search.cgi"; readfile("$file?$_SERVER[QUERY_STRING]"); ?>" trust me this does load the search.cgi and does so within my template. What I want to do is load the results of the search in the template also. So I changed the form action on the _search_query.html to index.php?a=cgi-bin/rm/exec/search But that only loads http://www.hhi.ie/index.php?search=1 I need it to load http://www.hhi.ie/index.php?a=cgi-bin/rm/exec/search&search=1 If i leave the $cgiurl$ as form action it loads http://www.hhi.ie/search.cgi?search=1 So I can only have form action as cg-bin/rm/exec/search.cgi This work but does not load the result in the template. Also I can use this as form action $search_url$ Same result as cg-bin/rm/exec/search.cgi Have you any ideas how I could get this to work. To load in the template without having to make more template pages. Thanks
(This post was edited by glav on Oct 8, 2007, 6:02 PM)
|
|
|  |
 |

Jake
Staff
/ Moderator

Oct 10, 2007, 10:22 AM
Post #18 of 18
(2917 views)
Shortcut
|
|
Re: [glav] Issues with including php scripts in templates
[In reply to]
|
Can't Post
|
|
Hi glav, Thanks for your post. I think we went over this in an email, but in case anyone else is wondering the problem here is that the search form values aren't being posted to the search.cgi script since it isn't being called directly. If this doesn't happen, the search engine doesn't know what data to process and therefore can't execute a proper search. We aren't really php experts, but if anyone else has similar problems feel free to post them and we can take a look! ----------------------------------------------------------- Cheers, Jake Swanson - 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.
|
|
|  |
|