Is it possible to specify window parameters when I open a new page for a link?

3 posts by 2 authors in: Forums > CMS Builder
Last Post: April 8, 2012   (RSS)

By joy - March 14, 2012 - edited: March 14, 2012

Hi, I'm new to using CMSB and I'm trying to convert an existing HTML site to use php and CMSB.

When I open a new window via a URL link, is there a way to specify window parameters?

Here is my exisiting html code below. In the CMSB interface, I do see the option to open in a new window, but I'm not sure how to specify additional parameters. Thanks for any assistance you can offer.

<A HREF='#'onClick="window.open('http://www.mydomain.com/map.html','_blank','width=500,height=600,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=no');return false" onmouseover="window.status='Map'; return true;">map for directions</A>.

Re: [joy] Is it possible to specify window parameters when I open a new page for a link?

Hi Joy,

I may be missing something, but if all you want to do is insert a map URL, the only thing you really need to use in the php viewer code would be a php call for appropriate the map URL.

Let's say that the map URL is stored in a text field called map_url, in an editor called companies, then your body code for a list page could be as easy as:

<?php foreach ($companiesRecords as $record ): ?>
<A HREF='#'onClick="window.open('<?php echo $record[map_url'] ?>','_blank','width=500,height=600,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=no');return false" onmouseover="window.status='Map'; return true;">map for directions</A>.
<?php endforeach; ?>

Or for a Detail page:
<A HREF='#'onClick="window.open('<?php echo $companiesRecord[map_url'] ?>','_blank','width=500,height=600,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=no');return false" onmouseover="window.status='Map'; return true;">map for directions</A>.

Of course you'd have to have the appropriate load records calls at the top of your page copied from your admin code generator.

I'd suggest including the following code just before the <A href code. It will make sure that if a urls does not have an http:// at it's start, one is added and the link is not broken.

For the List page:
<?php

if (!preg_match("/^http:\/\//", $record['map_url'])) {
$record['map_url'] = "http://" . $record['map_url']; }

?>
<?php endif ?>

For the detail page:

<?php

if (!preg_match("/^http:\/\//", $companiesRecord['map_url'])) {
$companiesRecord['map_url'] = "http://" . $companiesRecord['map_url']; }

?>
<?php endif ?>


If you want to change other parameters or add other information in your viewers, just replace the actual dynamic information with php calls to other fields in your Company records.

There's a lot of information on how CMSB works, converting html pages, and hundreds of "how to"
recipes in my CMSB Cookbook at http://www.thecmsbcookbook.com

Good luck with your pages.

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php