"Email this page" in CMS Builder page?

5 posts by 2 authors in: Forums > CMS Builder
Last Post: April 6, 2008   (RSS)

By matrix - April 4, 2008

Feeling not so smart here...tried everything I could think of but am having no luck creating an "Email this page" link for the news pages.

Here's the last link format I tried within the newsPage.php template:
<a href="mailto:?subject=<?php echo $record['headline'] ?>&body=<?php echo $record['_link'] ?>">

I had included the Record List code above that, which works so well with internal menus.

The headline is called nicely, although cut short, but I can't get the doggoned URL to display in the email subject.

Also tried <? echo $PHP_SELF; ?>, before figuring out all needed to be called through fields somewhere (is that right?).

How to do this, please?

Many, many thanks.
Happy Interactive Tools product user since 1999

Re: [matrix] "Email this page" in CMS Builder page?

By Dave - April 5, 2008

What is it outputting right now when you view source?

mailto: links can be a little tricky and are sometimes handled differently by different mail programs. Here's two things to watch for:

You often need to url encode the values. Otherwise, if there's a = or & in the headline the browser might get confused with the link. Url encodes uses sequences like this %3D (that's a =) to represent characters that otherwise have a special meaning in the url. You can add the PHP urlencode() function to your tag like this to automatically url encode:

<?php echo urlencode($record['headline']) ?>

This will display "this & that" as "this%20%26%20that".

Next, if the full link with HTTP isn't appearing you may need to add that. The simplest way is just to add it manually:

...&body=http://example.com/path/to/viewerDir/<?php echo $record['_link'] ?>"

If you want to get it automatically you could try something like this before the _link (assuming the link doesn't already include the http:// part):

<?php echo "http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/" ?>

There's no variable with the full url so we need piece it together from those others.

Hope that helps. If you need any more details or if that doesn't quite do it just let me know! :)
Dave Edis - Senior Developer
interactivetools.com

Re: [matrix] "Email this page" in CMS Builder page?

By Dave - April 6, 2008

Oh, ok. I think I was on the wrong track the whole time. I was thinking that you were working with the list viewer. But you're not you're working with the page viewer. Try adding this just below "getRecord":

$record = getRecord($options);

$thisPage = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . "?" . $record['num'];


It will define a variable called $thisPage that you can use like this: <?php echo $thisPage; ?>. I don't think you need to url encode it, but if you do, it would be like this: <?php echo urlencode($thisPage); ?>

I've made a note to add a $thisPage variable to an upcoming version. Thanks for the suggestion. I'm hoping this one works but do let me know if it's not quite right or there's any issues with the format of the url.

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] "Email this page" in CMS Builder page?

By matrix - April 6, 2008

Woohoo! You totally made my day, man!

Works absolutely perfectly! Thank you so much.

(Glad you'll be adding the variable as default, so useful! I'm going back now to add it to all the page templates.)

Thanks again.
Happy Interactive Tools product user since 1999