I’m trying to to do some basic formatting and styling of the email I
receive. Right now it’s all in one paragraph and I would like the
Message variable on a new line like the following (includes style tags
for clarity):
<b>Sender's Name</b> at <b>Sender's Email</b> has contacted you.
<b>Message:</b> My message
Here’s how it looks currently:
else{
$to = 'email@hidden'; //your admin address
$subject = 'Whoo-hoo!';
$body = $this->name . ' at ' . $this->email . ' has contacted
you. ' . 'Message: ' . $this->message . ' View it at http://
mysite.mobi.';
// $body = print_r($this,true); //basic awful-looking text version of
mar. debugging code.
mail($to,$subject,$body,'From: email@hidden','email@hidden
');
if(!is_null($strSession)) $_SESSION[$strSession] =
flash($strMessage);
return header('Location: ' . $strRedirectTo);
}
To force line-breaks in a plain-text e-mail, just add newlines, or to
be completely pedantic, return + newline. Try this:
define ('MAIL_BREAK',"rn");
Note that I used double-quotes rather than single-quotes, that’s
significant when you’re creating something with these backslash
“escape” characters like r, n, or t.
Now in your message, as you’re composing it, just inline one or two
MAIL_BREAK characters wherever you want a “paragraph”. It’s also
canonical to put two of these at the end of the body of your message.
$body = 'Howdy from the server.' . MAIL_BREAK . MAIL_BREAK . 'This is
a new paragraph';
Walter
On Mar 13, 2011, at 10:31 AM, Todd wrote:
I’m trying to to do some basic formatting and styling of the email I
receive. Right now it’s all in one paragraph and I would like the
Message variable on a new line like the following (includes style
tags for clarity):
<b>Sender's Name</b> at <b>Sender's Email</b> has contacted you.
<b>Message:</b> My message
Here’s how it looks currently:
else{
$to = 'email@hidden'; //your admin address
$subject = 'Whoo-hoo!';
$body = $this->name . ' at ' . $this->email . ' has contacted
you. ' . 'Message: ' . $this->message . ' View it at http://mysite.mobi
.';
// $body = print_r($this,true); //basic awful-looking text version
of mar. debugging code.
mail($to,$subject,$body,'From: email@hidden','email@hidden
');
if(!is_null($strSession)) $_SESSION[$strSession] =
flash($strMessage);
return header('Location: ' . $strRedirectTo);
}
Does “define (‘MAIL_BREAK’,“rn”);” get added to the model or
controller? No matter what I try I keep breaking it.
Todd
On Mar 13, 2011, at 11:35 AM, Walter Lee Davis wrote:
To force line-breaks in a plain-text e-mail, just add newlines, or
to be completely pedantic, return + newline. Try this:
define (‘MAIL_BREAK’,“rn”);
Note that I used double-quotes rather than single-quotes, that’s
significant when you’re creating something with these backslash
“escape” characters like r, n, or t.
Now in your message, as you’re composing it, just inline one or two
MAIL_BREAK characters wherever you want a “paragraph”. It’s also
canonical to put two of these at the end of the body of your message.
$body = 'Howdy from the server.' . MAIL_BREAK . MAIL_BREAK . 'This
is a new paragraph';
On Mar 13, 2011, at 10:31 AM, Todd wrote:
I’m trying to to do some basic formatting and styling of the email
I receive. Right now it’s all in one paragraph and I would like the
Message variable on a new line like the following (includes style
tags for clarity):
<b>Sender's Name</b> at <b>Sender's Email</b> has contacted you.
<b>Message:</b> My message
Here’s how it looks currently:
else{
$to = 'email@hidden'; //your admin address
$subject = 'Whoo-hoo!';
$body = $this->name . ' at ' . $this->email . ' has contacted
you. ' . 'Message: ' . $this->message . ' View it at http://mysite.mobi
.';
// $body = print_r($this,true); //basic awful-looking text version
of mar. debugging code.
mail($to,$subject,$body,'From: email@hidden','email@hidden
');
if(!is_null($strSession)) $_SESSION[$strSession] =
flash($strMessage);
return header('Location: ' . $strRedirectTo);
}
You could put it in your config file, or pretty much anywhere. When
you say it keeps breaking, what is happening for you? Try putting it
just ahead of the line where you use it.
Walter
On Mar 13, 2011, at 5:34 PM, Todd wrote:
Does “define (‘MAIL_BREAK’,“rn”);” get added to the model or
controller? No matter what I try I keep breaking it.
When you say it keeps breaking, what is happening for you?
I kept getting:
Parse error: syntax error, unexpected ‘.’
But now that I put it directly above where I’m using it in the model
it works as expected. Thank you. As for adding a bold style to a
variable, eg, $this->email . ’ has contacted you. ’ . , it does throw
an error. Is it possible to do this?
The form works and submits to the db as expected (that part was easy-
breezy). Upon successful submission I was originally redirecting to a
non-MAR controlled success page (success.php) but I want to pass the
“name” variable to the success page so I created a “success” template
and partial (_success.php) and placed them in the “views” directory.
So far so good. Here’s where it gets sketchy: I then created a new
“case” named “success” in the controller which, I’m sure, has screwy
syntax; no doubt I have unnecessary and duplicate stuff in the
controller. In short the name variable is not being passed.
Yeah, there’s a couple things I’m not clear about here. First, are you
posting to this or redirecting to it after a successful post to a
different controller path? If you’re not posting to it, then the
manage_result() method is completely wrong for this. Remember, its job
is to look and see if there are errors on the model. If there are,
then the errors are converted into a local (non-session-based flash
message) and the form reloads itself. If there aren’t any errors, then
the session-based flash message is filled with the success message
(third variable) and the user is redirected to the success path
(fourth variable). You have this fourth variable blank, which is
probably going to fail in Microsoft browsers, and is ambiguous anyway.
and back in whatever method you are using to vet your form submission,
be sure to change the success path to /yourmodel/success/$mar->id so
this case will be evaluated.
Well, the intent was to, upon successful submission, redirect to a
separate success page and in turn pass the “name” variable along to it.
Originally I didn’t care for the success flash message to appear on
the form page, hence the redirect, but at this point I’m ok with just
getting something to work, be it the flash success message posting to
the form page, just like the errors do, or passing the variable to the
success page (the redirect part works fine). Either is good. I can get
certain aspects to work but seem to lose the error checking in the
process. Very frustrated with myself.
Tried your suggestion but still I can’t get it to work.
Todd
On Mar 14, 2011, at 9:04 AM, Walter Lee Davis wrote:
First, are you posting to this or redirecting to it after a
successful post to a different controller path? If you’re not
posting to it, then the manage_result() method is completely wrong
for this.
and back in whatever method you are using to vet your form
submission, be sure to change the success path to /yourmodel/success/
$mar->id so this case will be evaluated.
Well, the intent was to, upon successful submission, redirect to a
separate success page and in turn pass the “name” variable along to
it.
Originally I didn’t care for the success flash message to appear on
the form page, hence the redirect, but at this point I’m ok with
just getting something to work, be it the flash success message
posting to the form page, just like the errors do, or passing the
variable to the success page (the redirect part works fine). Either
is good. I can get certain aspects to work but seem to lose the
error checking in the process. Very frustrated with myself.
Tried your suggestion but still I can’t get it to work.
In the case where you are dealing with the $_POST, try using this set
of options to the manage_result function:
Then on your success.php page or your _success.php partial (which you
probably don’t need since you already have the different outer
template, no need to make a separate partial for the middle of that if
you’re not loading it into the $out variable for playback within your
one outermost layout index.php file) then just don’t include the <?=
$flash ?> part, and you won’t see any flash messages. manage_result
will still set them, but you just don’t need to show them to the user.
Walter
Todd
On Mar 14, 2011, at 9:04 AM, Walter Lee Davis wrote:
First, are you posting to this or redirecting to it after a
successful post to a different controller path? If you’re not
posting to it, then the manage_result() method is completely wrong
for this.
and back in whatever method you are using to vet your form
submission, be sure to change the success path to /yourmodel/
success/$mar->id so this case will be evaluated.
You have larger issues then, probably in your routing.php file. Are
you serving this from a subfolder or from a domain? What is your model
named? I used mar, but realize you may have made that up for the
example. use model/action/id to create the link. If you have a recent
version of the MAR framework, like the fork that’s in Generate, then
there’s the ultra-succinct $model->link_to(‘verb’) helper function.
Walter
On Mar 14, 2011, at 1:14 PM, Todd wrote:
In the case where you are dealing with the $_POST, try using this
set of options to the manage_result function:
public_html
mar folder
controllers
models
routing.php
views
etc.
The model name is “mar” and the model file is named “mar_model.php”.
MAR v0.6
<?php
// this is the front controller, responsible for loading the proper
controller and passing the basic routing information
require_once('config.inc.php');
$segments = explode('/',str_replace('index.php','',
$_SERVER['REQUEST_URI']));
array_shift($segments); //first element is always blank
array_shift($segments); //remove second level, since you are running
in the /mar folder -- also this is fixed in the index.php view
// array_shift($segments);
$model = (isset($segments[0]) && !empty($segments[0])) ?
$segments[0] : 'mar'; //if a particular model is not chosen, default
to this
$verb = (isset($segments[1]) && !empty($segments[1])) ? $segments[1] :
'index'; //if a particular action is not requested, default to this
if(isset($segments[2]) && !empty($segments[2])) {
if(strpos($segments[2],'-') !== false) $segments[2] =
substr($segments[2], 0, strpos($segments[2],'-'));
$id = (int) preg_replace('/[^d]/','',$segments[2]);
}
$extra = (isset($segments[3]) && !empty($segments[3])) ?
$segments[3] : '';
$models = scandir(APP_ROOT . '/models');
foreach($models as $m){
if(!is_dir(APP_ROOT . '/models/' . $m) && file_exists(APP_ROOT . '/
models/' . $m)) include(APP_ROOT . '/models/' . $m);
}
if (file_exists(APP_ROOT . '/controllers/' . $model .
'_controller.php')) include(APP_ROOT . '/controllers/' . $model .
'_controller.php');
?>
T
On Mar 14, 2011, at 12:20 PM, Walter Lee Davis wrote:
You have larger issues then, probably in your routing.php file. Are
you serving this from a subfolder or from a domain? What is your
model named?
On Mar 14, 2011, at 1:14 PM, Todd wrote:
In the case where you are dealing with the $_POST, try using this
set of options to the manage_result function:
public_html
mar folder
controllers
models
routing.php
views
etc.
The model name is “mar” and the model file is named “mar_model.php”.
MAR v0.6
<?php
// this is the front controller, responsible for loading the proper
controller and passing the basic routing information
require_once('config.inc.php');
$segments = explode('/',str_replace('index.php','',
$_SERVER['REQUEST_URI']));
array_shift($segments); //first element is always blank
array_shift($segments); //remove second level, since you are running
in the /mar folder -- also this is fixed in the index.php view
// array_shift($segments);
$model = (isset($segments[0]) && !empty($segments[0])) ?
$segments[0] : 'mar'; //if a particular model is not chosen, default
to this
$verb = (isset($segments[1]) && !empty($segments[1])) ?
$segments[1] : 'index'; //if a particular action is not requested,
default to this
if(isset($segments[2]) && !empty($segments[2])) {
if(strpos($segments[2],'-') !== false) $segments[2] =
substr($segments[2], 0, strpos($segments[2],'-'));
$id = (int) preg_replace('/[^d]/','',$segments[2]);
}
$extra = (isset($segments[3]) && !empty($segments[3])) ?
$segments[3] : '';
$models = scandir(APP_ROOT . '/models');
foreach($models as $m){
if(!is_dir(APP_ROOT . '/models/' . $m) && file_exists(APP_ROOT . '/
models/' . $m)) include(APP_ROOT . '/models/' . $m);
}
if (file_exists(APP_ROOT . '/controllers/' . $model .
'_controller.php')) include(APP_ROOT . '/controllers/' . $model .
'_controller.php');
?>
T
On Mar 14, 2011, at 12:20 PM, Walter Lee Davis wrote:
You have larger issues then, probably in your routing.php file. Are
you serving this from a subfolder or from a domain? What is your
model named?
On Mar 14, 2011, at 1:14 PM, Todd wrote:
In the case where you are dealing with the $_POST, try using this
set of options to the manage_result function:
It’s still not working the way I want (though it does work) despite
some incorrect syntax. If anyone has been following and wants to take
a look at the key files then have at it. I’m taking a break.