"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: [Dave] "Email this page" in CMS Builder page?

By matrix - April 6, 2008

Thank you so much for your quick response.

It definitely helped, but no go, yet. I think we've narrowed it down to the record link issue.

I've tried both solutions, multiple times, multiple ways, and neither is writing the <?php echo $record['_link'] ?>.

Here are the solutions that came closest, with the error messages returned (using generic URLs here as example):

__________________
ONE -
<a href="mailto:?subject=<?php echo urlencode $record['title']?>&body=http://RightDomain.com/RightDirectory/<?php echo urlencode $record['_link']?>>"Click here to email page.</a>

ERROR MESSAGE RETURNED BY BROWSER:
Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' i

SECOND ATTEMPT (after reading up a little at http://us3.php.net/urlencode and adding parentheses)

<a href="mailto:?subject=<?php echo urlencode ($record['title'])?>&body=http://RightDomain.com/RightDirectory/<?php echo urlencode ($record['_link'])?>>"Click here to email page.</a>

ERROR MESSAGE IN SOURCE CODE:
<a href="mailto:?subject=The+Article+Title&body=http://RightDomain.com/RightDirectory/<br />
<b>Notice</b>: Undefined index: _link in <b>/RightPath/articlesPage.php</b> on line <b>113</b><br />
>"Click here to email page.</a>
___________________________

I even made sure to reload the "Records List" code above the Email Page code, figuring the page couldn't see the variable unless that happened, but no luck.

It feels so close, and I know we're spoiled by the ease with which you have made this happen in Article Manager:
<a href="mailto:?subject=$art_name_ue$&body=$url_thispage_ue$">

Is it possible to have the full code written out using the generic example above for those of us whose PHP expertise is light years behind yours? This surely is a super-useful snippet many of us will use.

Many, many, many thanks again.

M

PS: I never realized how beautiful your little $url_thispage_ue$ was until now. Thank you for that one! It's now in use on thousands of pages for our sites and those of clients.
Happy Interactive Tools product user since 1999

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