2 CMS questions

2 posts by 2 authors in: Forums > CMS Builder
Last Post: October 7, 2008   (RSS)

By townsoup - October 7, 2008 - edited: October 7, 2008

I recently purchased CMS but have used other IT products.

1.) On the homepagedetails.php category, is there a way to use Google maps as is dne with listing manager?

2.) On the homepagedetails.php I would like a field that links to an outside website. How do I make a field a hyperlink in htis category?

Thanks in advance!

Todd

Re: [townsoup] 2 CMS questions

By Kenny - October 7, 2008 - edited: October 7, 2008

Hi Todd,

In order to use Google Maps or Mapquest with CMS Builder, all you have to do is create the fields for address, city, and state and/or zip code.

If you pulled an address from Google Maps, it gives you a URL like this:

http://maps.google.com/maps?f=q&hl=en&geocode=&q=6+E+Chambers+St,+Cleburne,+TX+76031 (or something to that effect, but you can use this link structure - it will still work)


In your code you would replace the address with your corresponding echo statements like this:


http://maps.google.com/maps?f=q&hl=en&geocode=&q=<?php echo $record['address'] ?>+<?php echo $record['city'] ?>+<?php echo $record['state'] ?>+<?php echo $record['zip_code'] ?>

A link from Mapquest would look like this:

http://www.mapquest.com/maps/map.adp?address=<?php echo $record['address'] ?>&city=<?php echo $record['city'] ?>&state=<?php echo $record['state'] ?>&zipcode=<?php echo $record['zip_code'] ?>





To make an outside link, create a website link field in CMS Builder - normally make this a "text field".


In your code you would put:

<a target="_blank" href="<?php echo $record['web_site'] ?>"><?php echo $record['web_site'] ?></a>


When putting in web addresses in the back-end, it is important that they are complete links that include " http:// " If you are feeling up to it, you make your code insert the " http:// " if it is not there.

<?php
.
if (!preg_match("/^http:\/\//", $record['web_site'])) {
$record['web_site'] = "http://" . $record['web_site']; }
?>

<a href="<?php echo $record['web_site'] ?>"><?php echo $record['web_site'] ?></a>


Basically, what that's doing is checking for the presence of "http://" at the start of the text in this field. If it isn't found it's added in, otherwise the data is displayed as is.



For both of these, make sure you replace my example fields $record['web_site'] with your fields.


Hope this helps you out, but feel free to post back if you have more questions.


Kenny