I am using this code to add some buttons with shortcode in functions.php## Heading ## then it is working :
function add_after_post_content($content) {
if(!is_feed() && !is_home() && is_singular() && is_main_query()) {
$content .= '<p><b>Setup/Medicine Download<b></p>[maxbutton id="1"]';
$content .= '[maxbutton id="2"]';
$content .= '[maxbutton id="3"]';
}
return $content;
}
add_filter('the_content', 'add_after_post_content');
But when I add some Html code after that then it does not work :
function add_after_post_content($content) {
if(!is_feed() && !is_home() && is_singular() && is_main_query()) {
$content .= '<table style="border: solid 1px #ffffff;width:100%;">
<tbody>
<tr>
<td>
<h3><b><span style="color: #555; ">About Author</span> </b>
<input type="hidden" name="stats" value="2498">
</h3>you can be an author too, join mhktricks and show you skills</td>
<td style="border: solid 1px #ffffff;" align="right">
<a href="http://mhktricks.net/user-registration/" target="_blank">
<input class="p2graybtn" style="height: 26px; width:150px;" type="button" value="Join Us">
</a>
</td>
</tr>
</tbody>
</table>
<hr>
<table style="border: solid 1px #ffffff;">
<tbody>
<tr>
<td>
<?php echo get_avatar( get_the_author_meta( 'user_email' ), 70 ); ?>
</td>
<td style="border: solid 1px #ffffff;">
<table style="border: solid 1px #ffffff;">
<tbody>
<tr>
<td>
<span style="color: #555;font-size:20px;font-family: Open Sans;font-weight: 400;font-style: normal;text-decoration: none;">
<?php echo get_the_author(); ?>
</span>
<br><div style="margin-left:1px;">
<?php echo get_author_role(); ?>
<span style="position:relative;top:1px;margin-left:5px;"><img src="http://i2.wp.com/codex.onhax.net/img/verified.png" height="12" width="12"></span>
</div>
</td>
<td style="border: solid 1px #ffffff;">
<div style="margin-left: 3px;margin-top: -17px;border: #B8B8B8 1px solid;border-radius:2px;padding: 0px 5px 0px 5px;font-size:10px;">
<?php the_author_posts(); ?> POSTS</div>';
</td>
</tr>
</tbody>
</table><div style="margin-top:-12px;">
</div>
<div style="margin-left:3px;margin-top:2px;padding-right:60px;">
<?php the_author_meta( 'description' ); ?>
<a class="author-link" href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>" rel="author">
View all posts by me
<?php get_the_author(); ?>
<span class="meta-nav">→</span>
</a>
</div>
</td>
</tr>
</tbody>
</table>
<hr color="white">
<hr color="white">
<table style="border: solid 1px #ffffff;width:100%;">
<tbody>
<tr>
<td>
<h3><b><span style="color: #555; ">Discussion</span></b></h3>
share your knowledge.mind to help others</td>
<td style="border: solid 1px #ffffff;" align="right">
<a href="#" class="show-comments">
<input class="p2graybtn" style="height: 26px;" type="button" value="Toggle Comments">
</a>
</td>
</tr>
</tbody>
</table>';
}
return $content;
}
add_filter('the_content', 'add_after_post_content');
When I add the above code the page even doesn't load.
I just want to add author box below posts but it does not work. Help Please !
If you'd bothered to look, you have a ' in your html, which is terminating your string assignment:
[...long snip...] the_author_posts(); ?> POSTS</div>';
^---
</td>
which turns that </td> into PHP code, causing a fatal parse error.
This is why massive multi-line strings like this are a horrible idea. If you need to dump text like that, use a HEREDOC, or drop out of PHP mode. e.g.
$content = <<<EOL
blah blah blah all your html here blah blah blah
EOL;
HEREDOCs removes the need to worry about quotes.
You should also turn on display_errors and error_reporting, which would have told you about the fatal error. They should NEVER be off on a devel/debug system.
Related
I have set up a site and added a contact form into it. Php mailer work correctly but when the mail text arrives to me there is no empty between the letters. All of them is adjoining. I want to list titles one under to other mailer.php. The code is like this
require("class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 1;
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl';
$mail->Host = "smtp.gmail.com";
$mail->Port = 465; // or 587
$mail->IsHTML(true);
$mail->SetLanguage("tr", "phpmailer/language");
$mail->CharSet ="utf-8";
$mail->Username = "sample";
$mail->Password = "sample";
$mail->SetFrom("sample#sample.com", "Baslik");
$mail->AddAddress("sample#sample.com");
$mail->Subject = "Siteden Gönderildi";
include("iletisim.html");
$mail->Body = $frmName= $_POST["frmName"].
$frmCity= $_POST["frmCity"] .
$adressatiri= $_POST["adressatiri"].
$adressatiri2= $_POST["adressatiri2"].
$email= $_POST["email"] .
$frmTelephone= $_POST["frmTelephone"] .
$frmPhoneType= $_POST["frmPhoneType"] .
$frmContactBy= $_POST["frmContactBy"] .
$frmBestTime= $_POST["frmBestTime"] .
$frmMessage= $_POST["frmMessage"];
if(!$mail->Send()){
echo "Mailer Error: ".$mail->ErrorInfo;
} else {
echo "Mesajınız Gonderilmistir";
}
?>
and contact.html file is like this. If you can help me i will be very happy. Because i didnt solve this problem throughout one
<!doctype html>
<html>
<head>
<link rel="Shortcut Icon" href="image/favicon.ico" type="image/x-icon">
<meta charset="utf-8">
<title>Sena DOĞAN Kişisel Web Sitesi</title>
<style type="text/css">
body, p, table, th, td, div {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
th {
background-color:#0080C0;
color:white;
font-weight:bold;
font-size:18px;
border: 1px solid #0080C0;
}
input.text, textarea {
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
width: 99%;
}
.text:focus, textarea:focus {
background-color: #FFFACC;
border: 1px solid #000000;
}
#mydiv {
margin-left: auto ;
margin-right: auto ;
width: 500px;
text-align: left;
}
td.colone {
text-align: right;
vertical-align: top;
padding-top:6px;
width:20%;
}
td.coltwo {
color:red;
text-align: center;
vertical-align: top;
padding-top:9px;
}
td.colthree {
width:80%
}
table.border {
border: 1px solid #0080C0;
border-collapse: collapse;
}
</style>
<link href="banner.css" rel="stylesheet" type="text/css">
}
</head>
<body>
<div class="container"> <img src="image/Sena banner.png" width="999" height="258" alt="KTU"/>
<div id="navbar">
<ul style="">
<li style="">Ana Sayfa</li>
<li> Hakkında</li>
<li> Projeler</li>
<li>Deneyim</li>
<li> Galeri</li>
<li> İletişim</li>
<br>
<br>
<br></ul>
<br/>
<form method="POST" action="mailer.php" enctype="multipart/form-data">
<input type="hidden" value="samplecontactus.html" name="referer">
<table class="border" width="500" cellpadding="3" cellspacing="0">
<tr>
<th colspan="3" align="center">İletişim İçin Lütfen Aşağıdaki Kutuları Doldurun</th>
</tr>
<tr>
<td colspan="3"><div style="height:5px;"></div></td>
</tr>
<tr>
<td class="colone">Ad Soyad</td>
<td class="coltwo">*</td>
<td class="colthree"><input class="text" type="text" name="frmName" style="width:98%;"></td>
</tr>
<tr>
<td class="colone">Şehir</td>
<td class="coltwo"> </td>
<td class="colthree"><input class="text" type="text" name="frmCity" style="width:98%;"></td>
</tr>
<tr>
<td class="colone">Adres</td>
<td class="coltwo"> </td>
<td class="colthree"><input class="text" type="text" name="adressatiri" style="width:98%;"></td>
</tr>
<tr>
<td class="colone">Adres-2</td>
<td class="coltwo"> </td>
<td class="colthree"><input class="text" type="text" name="adressatiri2" style="width:98%;"></td>
</tr>
<tr>
<td class="colone">E-posta</td>
<td class="coltwo">*</td>
<td class="colthree"><input class="text" type="text" name="email" style="width:98%;"></td>
</tr>
<tr>
<td class="colone">Telefon</td>
<td class="coltwo"> </td>
<td class="colthree">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td width="200"><input class="text" type="text" name="frmTelephone" style="width:200px;"></td>
<td>
<select size="1" name="frmPhoneType">
<option value="Home">Ev</option>
<option value="Worx">İş</option>
</select>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="colone">Görüşme Şekli</td>
<td class="coltwo"> </td>
<td class="colthree">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td width="1">
<select size="1" name="frmContactBy">
<option value="Telefon">Telefon</option>
<option value="Email">E-Posta</option>
</select>
</td>
<td>
<select size="1" name="frmBestTime">
<option value="Morning">Gündüz</option>
<option value="Afternoon">Öğle</option>
<option value="Evening">Akşam</option>
</select>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="colone">Mesaj</td>
<td class="coltwo">*</td>
<td class="colthree"><textarea class="text" name="frmMessage" style="width:98%;height:100px;"></textarea></td>
</tr>
<tr>
<td class="colone" colspan="2"> </td>
<td class="colthree"><input type="submit" value="Gönder" name="submit"><input type="reset" value="Reset" name="reset"></td>
</tr>
<tr>
<td colspan="3"><div style="height:5px;"></div></td>
</tr>
</table>
</form>
</div>
<h2><span style="color: #ED0F13"><center>
</center>
</span></h2>
<blockquote>
<p> </p>
<p><span class="copyright" style="text-align: center"><span class="copyright"><center class="copyright">Copyright © 2018 DOĞAN Web Tasarım™</center><span class="copyright"><span class="copyright"></span></span>
</center>
</span></span></p>
</blockquote>
<p><span class="imagefloatleft">
<article id="123"> </article>
</span>
<span class="imagefloatleft">
<article id="text"> </article>
</span>
<span class="imagefloatleft">
<article id="text"> </article>
</span>
<span class="imagefloatleft">
<article id="text"> </article>
</span>
<span class="imagefloatleft">
<article id="text"> </article>
</span>
<span class="imagefloatleft">
<article id="text"> </article>
</span><span class="imagefloatleft">
<article id="text"> </article>
</span><span class="imagefloatleft">
<article id="text"></article>
</span></p>
</div>
</body>
</html>
It's because HTML collapses white space. The easiest way to fix this is to convert real line breaks into HTML break tags in your message body:
$mail->Body = nl2br($mail->Body);
As a result of my researches I have found a solution like this
<a><span style='font-weight: bold;'>İsim:</span> ".$_POST["frmName"]."</a><br>
<a><span style='font-weight: bold;'>Şehir:</span> ".$_POST["frmCity"]."</a><br>
<a><span style='font-weight: bold;'>Adres 1:</span> ".$_POST["adressatiri"]."</a><br>
<a><span style='font-weight: bold;'>Adres 2:</span> ".$_POST["adressatiri2"]."</a><br>
<a><span style='font-weight: bold;'>E-posta:</span> ".$_POST["email"]."</a><br>
<a><span style='font-weight: bold;'>Telefon:</span> ".$_POST["frmTelephone"]."</a><br>
<a><span style='font-weight: bold;'>Telefon Tipi:</span> ".$_POST["frmPhoneType"]."</a><br>
<a><span style='font-weight: bold;'>Görüşme Şekli:</span> ".$_POST["frmContactBy"]."</a><br>
<a><span style='font-weight: bold;'>En uygun zaman:</span> ".$_POST["frmBestTime"]."</a><br>
<a><span style='font-weight: bold;'>Mesaj:</span> ".$_POST["frmMessage"]."</a>
This question already has answers here:
Change Text And Background Color Of Table Cell Based On Text Value
(4 answers)
Closed 5 years ago.
Hi am struggling with this:
I have a PHP snippet that I want to apply to my web page in order to change table row color if the text is equivalent to "PRIORITY" or "SUPPORT". I need help to implement the php into the HTML part of the tables.
SNIPPET
<?php
function switchColor($rowValue) {
//Define the colors first
$color1 = '#e2e2e2';
$color2 = '#00ff00';
$color3 = '#0000ff';
switch ($rowValue) {
case 'PRIORITY':
echo $color1;
break;
case 'ADVISORY':
echo $color2;
break;
default:
echo $color3;
}
}
?>
I NEED TO IMPLEMENT IN THIS TABLE
<tr class="tablerow<?php echo $count; ?>">
<td style="background-color: #92c38e; text-align:
center;">
<span style="font-size: medium;"><?php print
strip_tags($category_name) ?></span>
</td>
<td style="background-color: #92c38e; text-align:
center;">
<?php foreach($category as $num=>$categor){
if($num != sizeof($category)-1){
?>
<span style="color: #ffffff; font-size:
medium;" data-id="<?php echo $categor['item_id']; ?>"><?php print
strip_tags($categor['item_name']); ?></span>, 
<?php } else {?>
<span style="color: #ffffff; font-size:
medium;" data-id="<?php echo $categor['item_id']; ?>"><?php print
strip_tags($categor['item_name']); ?></span>
<?php } } ?>
</td>
<!--THIS IS THE COLUMN WHERE THE CELL SHOULD CHANGE COLOR WHEN THE TEXT IS EQUIVALENT TO THE WORDS "PRIORITY OR ADVISORY-->
<td style="background-color: #92c38e; text-align:
center;">
<span style="color: #ffffff; font-size: medium;">
<?php print strip_tags($category[0]['status']); ?></span>
</td>
</tr>
I need help into formulating the correct PHP syntax in order to apply the switchColor function from the snippet.
Here
<td style="background-color: #92c38e; text-align:
center;">
you already have the structure, you just need the effective background-color value:
<td style="background-color: <?php echo switchColor(strip_tags($category[0]['status'])); ?>; text-align:
center;">
At least this is the solution if I understood well your question. If not, let me know.
You can set the table row color like:
table, th, td {
border: 1px solid black;
}
<table>
<tr bgcolor="#FF0000">
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
</table>
In your case call the function instead of passing the hard code color value like:
<tr bgcolor="<?php switchColor('variable that contains the value passed here') ?>">
You can make class for your row table and don't use function on php. For example
<tr class="tablerow<?php echo $count; ?> row_<? echo $rowValue; ?>"></tr>
And add this class to CSS.
You can simplify it by using CSS. Just have a CSS class for each type of priority, and you will just have to add the good class to the good row.
tr {background:yellow ; }
tr.PRIORITY { background:red; }
tr.ADVISORY { background:blue ; }
table { width:100% ; }
Here is an example without PHP just to see how it works and how it should be rendered in html source
<table>
<tr class="PRIORITY"><td> </td></tr>
<tr class="ADVISORY"><td> </td></tr>
<tr class=""><td> </td></tr>
<tr class=""><td> </td></tr>
</table>
<hr />
Here is what you have to do in php : just "echo" your priority level in class of your tr and that's it.
<table>
<?php foreach ( $rows as $row ) { ?>
<tr class="tablerow<?php echo $count; ?> <?php echo $row['YourVarWithPriority'] ; ?>"><td> </td></tr>
<?php } ?>
</table>
If you really have to use this particular function, I'd do this:
<?php
function switchColor($rowValue) {
//Define the colors first
$color1 = '#e2e2e2';
$color2 = '#00ff00';
$color3 = '#0000ff';
switch ($rowValue) {
case 'PRIORITY': ?>
<td style="background-color: <?php echo $color1?>" text-align: center;">
<span style="color: #ffffff; font-size: medium;"><?php echo $rowValue?>
</span>
</td>
<?php
break;
case 'ADVISORY': ?>
<td style="background-color: <?php echo $color2?>" text-align: center;">
<span style="color: #ffffff; font-size: medium;"><?php echo $rowValue?>
</span>
</td>
<?php
break;
default: ?>
<td style="background-color: <?php echo $color3?>" text-align: center;">
<span style="color: #ffffff; font-size: medium;"><?php echo $rowValue?>
</span>
</td>
<?php
}
}
?>
And then in the HTML :
<tr class="tablerow<?php echo $count; ?>">
<td style="background-color: #92c38e; text-align:
center;">
<span style="font-size: medium;"><?php print
strip_tags($category_name) ?></span>
</td>
<td style="background-color: #92c38e; text-align:
center;">
<?php foreach($category as $num=>$categor){
if($num != sizeof($category)-1){
?>
<span style="color: #ffffff; font-size:
medium;" data-id="<?php echo $categor['item_id']; ?>"><?php print
strip_tags($categor['item_name']); ?></span>, 
<?php } else {?>
<span style="color: #ffffff; font-size:
medium;" data-id="<?php echo $categor['item_id']; ?>"><?php print
strip_tags($categor['item_name']); ?></span>
<?php } } ?>
</td>
<!--THIS IS THE COLUMN WHERE THE CELL SHOULD CHANGE COLOR WHEN THE TEXT IS EQUIVALENT TO THE WORDS "PRIORITY OR ADVISORY-->
<?php switchColor(strip_tags($category[0]['status']);)?>
The code provided is while-loop, which work, part of the loop is to update database and to return the updated info back to loop that work too. The problem I am having is if the return result is more than one it should not loop that result only echo it once.
I have tried other ways of doing this, but nothing giving me the result I need, I have the amount of knowledge I have on PHP. If someone could please help me, there help would be greatly appreciated.
<?php
//////////////////////// non-spouse kid start ///////////////////////
$nonspouseKidSql=("SELECT * FROM familyTree WHERE memberEmail='$login_mem' AND familyRelationship='son' AND familySide='other' OR memberEmail='$login_mem' AND familyRelationship='daughter' AND familySide='other' OR fam
ilyEmail='$login_mem' AND familyRelationship='father' AND familySide='other' OR familyEmail='$login_mem' AND familyRelationship='mother' AND familySide='other'");
$nonspouseKidQuery=mysql_query($nonspouseKidSql)or die ("error 1 Sorry we have a mysql error!");
$num_rowsNonspouseKid=mysql_num_rows($nonspouseKidQuery);
if ($num_rowsNonspouseKid < 1){echo '';}
else{
while($getnonspouseKidRow=mysql_fetch_array($nonspouseKidQuery)){
$getnonspouseKidEmail = $getnonspouseKidRow['familyEmail'];
$getNSPEmail = $getnonspouseKidRow['memberEmail'];
$nonspouseKid_relationship = $getnonspouseKidRow['familyRelationship'];
if($getNSPEmail == $login_mem){$nonspouseKidEmail = $getnonspouseKidEmail;}elseif($getnonspouseKidEmail == $login_mem){$nonspouseKidEmail = $getNSPEmail;}
$sql=("SELECT * FROM members WHERE email='$nonspouseKidEmail'");
$query=mysql_query($sql)or die ("error 1 Sorry we have a mysql error!");
$num_rows=mysql_num_rows($query);
while($row=mysql_fetch_array($query)){
$familyNonspouseKid_id = $row["id"];
$familyNonspouseKid_firstName = $row["firstName"];
$familyNonspouseKid_lastName = $row["lastName"];
$familyNonspouseKid_email= $row["email"];
$familyNonspouseKid_profile_pic = $row["profile_pic"];
$familyNonspouseKid_status = $row["status"];
$familyNonspouseKid_gender = $row["gender"];
if($nonspouseKid_relationship=="son"){$familyNonspouseKid_relationship ='son';}elseif($nonspouseKid_relationship=="daughter"){$familyNonspouseKid_relationship ='daughter';}
$member_familyPicNonspouseSon='/home/users/web/b2072/moo.poryniticom/profilePic/'.$familyNonspouseKid_id.'/'.$familyNonspouseKid_profile_pic.'';
if($familyNonspouseKid_profile_pic!==""){
$member_familyPicNonspouseSon='<div id="connection_nonSpouseKid" class="connection_nonSpouseKid"></div><div id="memFamilyPic_nonSpouseKid" class="memFamilyPic_nonSpouseKid"><a href="headstoneViewMember.php?userName='.
$familyNonspouseKid_email.'" id="'.$familyNonspouseKid_id.'" class="display_familyInfo"><img src="/profilePic/'.$familyNonspouseKid_id.'/'.$familyNonspouseKid_profile_pic.'" style="padding: 1px 1px 1px 1px;"
class="memFamilyPic_border" width="60" height="60" border="0" alt="" /></a><div id="familyDisplayDiv'.$familyNonspouseKid_id.'" class="familyDisplayDiv" style="display:none">
<table width="100%">
<tr>
<td align="left" valign="middle"><span style=" font-size: 16px; color:#999999 ;">Your '.$familyNonspouseKid_relationship.'</span></td>
</tr>
<tr>
<td align="left" valign="middle"><span style=" font-size: 16px; color:#999999 ;">'.$familyNonspouseKid_firstName.' '.$familyNonspouseKid_lastName.'</span></td>
</tr>
</table>
</div>
</div>';
}else{
$member_familyPicNonspouseSon='<div id="connection_non-spouseKid" class="connection_nonSpouseKid"></div><div id="memFamilyPic_nonSpouseKid" class="memFamilyPic_nonSpouseKid"><a href="headstoneViewMember.php?userName='.
$familyNonspouseKid_email.'" id="'.$familyNonspouseKid_id.'" class="display_familyInfo"><img src="/profilePic/default/default_profilePic.png"style="padding: 1px 1px 1px 1px;" class="memFamilyPic_border" width="60"
height="60" border="0" alt=""/></a>
<div id="familyDisplayDiv'.$familyNonspouseKid_id.'" class="familyDisplayDiv" style="display:none">
<table width="100%">
<tr>
<td align="left" valign="middle"><span style=" font-size: 16px; color:#999999 ;">Your '.$familyNonspouseKid_relationship.'</span></td>
</tr>
<tr>
<td align="left" valign="middle"><span style=" font-size: 16px; color:#999999 ;">'.$familyNonspouseKid_firstName.' '.$familyNonspouseKid_lastName.'</span></td>
</tr>
</table>
</div>
</div>';
}
$member_familyPicNonspouseDaughter='/home/users/web/b2072/moo.poryniticom/profilePic/'.$familyNonspouseKid_id.'/'.$familyNonspouseKid_profile_pic.'';
if($familyNonspouseKid_profile_pic!==""){
$member_familyPicNonspouseDaughter='<div id="connection_nonSpouseKid" class="connection_nonSpouseKid"></div><div id="memFamilyPic_nonSpouseKid" class="memFamilyPic_nonSpouseKid"><a
href="headstoneViewMember.php?userName='.
$familyNonspouseKid_email.'" id="'.$familyNonspouseKid_id.'" class="display_familyInfo"><img src="/profilePic/'.$familyNonspouseKid_id.'/'.$familyNonspouseKid_profile_pic.'" style="padding: 1px 1px 1px 1px;"
class="memFamilyPic_border" width="60" height="60" border="0" alt="" /></a>
<div id="familyDisplayDiv'.$familyNonspouseKid_id.'" class="familyDisplayDiv" style="display:none">
<table width="100%">
<tr>
<td align="left" valign="middle"><span style=" font-size: 16px; color:#999999 ;">Your '.$familyNonspouseKid_relationship.'</span></td>
</tr>
<tr>
<td align="left" valign="middle"><span style=" font-size: 16px; color:#999999 ;">'.$familyNonspouseKid_firstName.' '.$familyNonspouseKid_lastName.'</span></td>
</tr>
</table>
</div>
</div>';
}else{
$member_familyPicNonspouseDaughter='<div id="connection_nonSpouseKid" class="connection_nonSpouseKid"></div><div id="memFamilyPic_nonSpouseKid" class="memFamilyPic_nonSpouseKid"><a
href="headstoneViewMember.php?userName='.
$familyNonspouseKid_email.'" id="'.$familyNonspouseKid_id.'" class="display_familyInfo"><img src="/profilePic/default/default_profilePic.png"style="padding: 1px 1px 1px 1px;" class="memFamilyPic_border" width="60"
height="60" border="0" alt=""/></a>
<div id="familyDisplayDiv'.$familyNonspouseKid_id.'" class="familyDisplayDiv" style="display:none">
<table width="100%">
<tr>
<td align="left" valign="middle"><span style=" font-size: 16px; color:#999999 ;">Your '.$familyNonspouseKid_relationship.'</span></td>
</tr>
<tr>
<td align="left" valign="middle"><span style=" font-size: 16px; color:#999999 ;">'.$familyNonspouseKid_firstName.' '.$familyNonspouseKid_lastName.'</span></td>
</tr>
</table>
</div>
</div>';
}
if($familyNonspouseKid_relationship =='son'){echo $member_familyPicNonspouseSon;}else{echo $member_familyPicNonspouseDaughter;}
}
?>
<?php
//////// non-spouse kid end //////////////////////////////
?>
<?php
//////////////// child parent not spouse start ////////
?>
<div id="connection_childParent" class="connection_childParent"></div>
<div id="memFamilyPic_childParent" class="memFamilyPic_childParent">
<?php
$getGender = $mem["gender"];
if($getGender=='male'){$parentGender='Mother';}else{$parentGender='Father';}
$parentNameSql=mysql_query("SELECT * FROM familyTree WHERE memberEmail='$nonspouseKidEmail' AND familyRelationship='mother' OR memberEmail='$nonspouseKidEmail' AND familyRelationship='father'")or die ("Sorry can't
get parent name!");
$parentNameRow=mysql_fetch_array($parentNameSql);
$parentName = $parentNameRow['familySide'];
$childParentSql=mysql_query("SELECT * FROM familyTree WHERE memberEmail='$login_mem' AND familyRelationship='childmother' AND child_Id='$familyNonspouseKid_id' OR memberEmail='$login_mem' AND
familyRelationship='childfather' AND child_Id='$familyNonspouseKid_id'")or die ("Sorry can't get child parent!");
$childParentRow=mysql_fetch_array($childParentSql);
if($childParentRow < 1){echo '<p id="'.$familyNonspouseKid_id.'" class="mysql_returnNonspouseKid" align="center" style="color: #999; font-size:13px;">Child '.$parentGender.'</p>';
}else if($childParentRow > 2){
$childParentEmail = $childParentRow['familyEmail'];
$familyChildParent_relationship = $childParentRow["familyRelationship"];
$childParent=("SELECT * FROM members WHERE email='$childParentEmail'");
$query=mysql_query($childParent)or die ("error 1 Sorry we have a mysql error!");
$num_rows=mysql_num_rows($query);
if($childParentRow > 2){
while($row=mysql_fetch_array($query)){
$familyChildParent_id = $row["id"];
$familyChildParent_firstName = $row["firstName"];
$familyChildParent_lastName=$row["lastName"];
$familyChildParent_email=$row["email"];
$familyChildParent_profile_pic = $row["profile_pic"];
$familyChildParent_status=$row["status"];
$member_familyPicChildParent='/home/users/web/b2072/moo.poryniticom/profilePic/'.$familyChildParent_id.'/'.$familyChildParent_profile_pic.'';
if($familyChildParent_profile_pic!==""){
$member_familyPicChildParent='<a href="headstoneViewMember.php?userName='.$familyChildParent_email.'" id="'.$familyChildParent_id.'" class="display_familyInfo"><img src="/profilePic/'.$familyChildParent_id.'/'.
$familyChildParent_profile_pic.'" style="padding: 1px 1px 1px 1px;" id="memFamilyPic_border'.$familyChildParent_id.'" class="memFamilyPic_border" width="60" height="60" border="0" alt="" /></a>';
}else{
$member_familyPicChildParent='<a href="headstoneViewMember.php?userName='.$familyChildParent_email.'" id="'.$familyChildParent_id.'" class="display_familyInfo"><img
src="/profilePic/default/default_profilePic.png"style="padding: 1px 1px 1px 1px;" id="memFamilyPic_border'.$familyChildParent_id.'" class="memFamilyPic_border" width="60" height="60" border="0" alt=""/></a>';
}
}
if($familyChildParent_relationship =='childmother' or $familyChildParent_relationship =='childfather'){echo $member_familyPicChildParent;}
}}else{}
?>
<div id="familyDisplayDiv<?php echo $familyChildParent_id; ?>" class="familyDisplayDiv" style="display:none">
<table width="100%">
<tr>
<td align="left" valign="middle"><span style=" font-size: 16px; color:#999999 ;">Your <?php echo $familyChildParent_relationship; ?></span></td>
</tr>
<tr>
<td align="left" valign="middle"><span style=" font-size: 16px; color:#999999 ;"><?php echo $familyChildParent_firstName; ?> <?php echo $familyChildParent_lastName; ?></span></td>
</tr>
</table>
</div>
</div>
<?php
}}
///////////////// child parent not spouse end //////////////
?>
I am trying to generate pdf using dom pdf
But in header part of pdf, image and text are overlapping.
Couldn't identify what exactly is wrong in my code?
CodeIgniter controller function:
$dompdf = new Dompdf();
$dompdf->set_option('enable_css_float', true);
$contxt = stream_context_create([
'ssl' => [
'verify_peer' => FALSE,
'verify_peer_name' => FALSE,
'allow_self_signed'=> TRUE
]
]);
$options = new Options();
$dompdf->setHttpContext($contxt);
$dompdf->set_option('isRemoteEnabled', true);
$dompdf->set_option('debugKeepTemp', true);
$dompdf->set_option('isHtml5ParserEnabled', true);
$dompdf->loadHtml($pdfdata);
// (Optional) Setup the paper size and orientation
$dompdf->setPaper('A4', 'portrait');
// Render the HTML as PDF
$dompdf->render();
$output = $dompdf->output();
Codeigniter View
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!--[if IE]><meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'><![endif]-->
<link rel="stylesheet" href="<?php echo CSS_PATH_BACKEND; ?>bootstrap.min.css">
<style>
#page { margin: 20px 30px; }
.table>tbody>tr>td, .table>tbody>tr>th, .table>tfoot>tr>td, .table>tfoot>tr>th, .table>thead>tr>td, .table>thead>tr>th{padding:6px;}
.table-bordered{border:2px solid #000;}
.table-bordered>tbody>tr>td, .table-bordered>tbody>tr>th, .table-bordered>tfoot>tr>td, .table-bordered>tfoot>tr>th, .table-bordered>thead>tr>td, .table-bordered>thead>tr>th{border:2px solid #000;}
.list-inline>li{ display: inline-block;
padding-right: 35px;
padding-left: 35px;
padding-top: 10px;
font-weight: 700;}
body{font-size:13px;}
.table>tbody>tr>td, .table>tbody>tr>th, .table>tfoot>tr>td, .table>tfoot>tr>th, .table>thead>tr>td, .table>thead>tr>th{padding:5px 0 5px 10px;}
.goods-table td{border:2px solid #000; }
thead:before, thead:after { display: none; }
tbody:before, tbody:after { display: none; }
tbody:before, tbody:after { display: none; }
.invoice tr td{}
.product_invoice td{padding:4px 5px !important;}
li{padding: 10px 0;}
li:before{content:''; font-size:60px; line-height:20px; vertical-align:middle;}
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-xs-12">
<table class="table goods-table" style="margin-bottom: 0; font-size: 13px; border-collapse: collapse;">
<tbody>
<tr>
<td>
<div class="invoice-title">
<?php
$seg = $this->uri->segment(2);
if ($seg == "preview") {
?>
<img src="http://www.example.com/images/backend/logo_pdf.png" style="margin: 0 auto;display: block;" width="380px" height="76px" class="text-center" alt="logo"/>
<?php
} else {
?>
<img src="http://www.example.com/images/backend/logo_pdf.png" style="margin: 0 auto;display: block;width:380px;height:76px;" width="380px" height="76px" class="text-center" alt="logo"/>
<?php } ?>
<p style="padding: 5px 0 0 0;margin: 0;font-size: 13px;text-align: center;" class="text-center">Corporate Office: Some address</p>
<p style="padding: 0;margin: 0;font-size: 13px;text-align: center;" class="text-center">Phone: 87945456 Cell: 321456789 Email: info#example.com Website: www.example.com</p>
</div>
<div class="invoice-title">
<span class="text-center" style="margin: 5px 0 0 0;font-weight:700;text-align: center;display: block;font-size: 18px;">TAX INVOICE CUM CHALLAN</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="">
<div class="">
<div class="table-responsive">
<!--<table class="table table-condensed">-->
<table class="table goods-table" style="margin-bottom: 0; font-size: 13px; border-collapse: collapse;">
<tbody>
<tr style="border:2px solid #000;">
<td rowspan="4" style="width:40%;" colspan="2">
<!--StartFragment-->
<p style="padding: 0;margin: 0;font-size: 13px;"><span >To,</span></p>
<p style="padding: 0;margin: 0;font-weight: 700;font-size: 13px;"><span ><?php echo $customer['name']; ?></span></p>
<p style="padding: 0;margin: 0;font-size: 13px;"><span ><?php echo $customer['address']; ?></span></p>
<p style="padding: 0;margin: 0;font-size: 13px;"><span ><?php echo $customer['address1']; ?></span></p>
<p style="padding: 0;margin: 0;font-size: 13px;"><span ><?php echo $customer['city']; ?></span></p>
<p style="padding: 0;margin: 0;font-size: 13px;"><span >Phone No: <?php echo $customer['contact_no']; ?></span></p>
</td>
<td style="vertical-align:middle;width:30%;border:2px solid #000;">Invoice No: <span style="font-weight: 700;"><?php echo $invoice['invoice_no']; ?></span></td>
<td style="vertical-align:middle;width:30%;border:1px solid #000;" colspan="3" >Contact Person: <span style="font-weight: 700;"><?php echo ucwords($customer['contact_person_name']); ?></span></td>
</tr>
<tr style="border:2px solid #000;">
<td style="vertical-align:middle;">Date: <span style="font-weight: 700;"><?php echo date('d M Y', strtotime($invoice['created_date'])); ?></span></td>
<td style="vertical-align:middle;" colspan="3">Mobile No: <span style="font-weight: 700;"><?php echo ucwords($customer['contact_person_no']); ?></span></td>
</tr>
<tr style="border:2px solid #000;">
<td style="line-height: 1;vertical-align:middle;" rowspan="2">RIN No: <span style="font-weight: 700;">87455454</span></td>
</tr>
<tr style="border:2px solid #000;">
<td style="line-height: 1;vertical-align:middle;" colspan="3"> VAT No: <span style="font-weight: 700;"></span></td>
</tr>
<tr style="border:2px solid #000;">
<!--<td >Company Executive: <?php echo ucwords($user['fname'] . ' ' . $user['lname']); ?></td>-->
<td colspan="1">Date of Activation: <span style="font-weight: 700;"><?php echo date('d M Y', strtotime($invoice['activation_date'])); ?></span></td>
<td colspan="3">Next Renewal: <span style="font-weight: 700;"><?php echo date('d M Y', strtotime($invoice['renewal_date'])); ?></span></td>
</tr>
</tbody>
</table>
<table width="100%" class="table goods-table invoice" style="margin-bottom: 0; font-size: 12px; border-top: 1px solid #202020; ">
<tbody>
<tr>
<td style="font-weight: 700;font-size: 13px;width:10%;">Sr. No</td>
<td style="font-weight: 700;font-size: 13px;width:15%;">Software ID</td>
<td style="font-weight: 700;font-size: 13px;width:35%;">Description</td>
<td style="font-weight: 700;font-size: 13px;width:10%;">Quantity</td>
<td style="font-weight: 700;font-size: 13px;width:15%;">Unit Price (<img src="http://i.stack.imgur.com/nGbfO.png" width="8" height="10">)</td>
<td style="font-weight: 700;font-size: 13px;width:15%" colspan="2">Total Price (<img src="http://i.stack.imgur.com/nGbfO.png" width="8" height="10">)</td>
</tr>
<?php
$cnt = 1;
foreach ($product_invoice as $key => $value) {
?> <tr <?php
if (count($product_invoice) < 9) {
echo 'class';
} else {
echo 'class="product_invoice"';
}
?>>
<td
<?php if (count($product_invoice) == 1) { ?> style="height:650px;"<?php } ?>
<?php if (count($product_invoice) == 2 && ($key == (count($product_invoice)) - 1)) { ?> style="height:590px;"<?php } ?>
<?php if (count($product_invoice) == 3 && ($key == (count($product_invoice)) - 1)) { ?> style="height:180px;"<?php } ?>
<?php if (count($product_invoice) == 4 && ($key == (count($product_invoice)) - 1)) { ?> style="height:160px;"<?php } ?>
<?php if (count($product_invoice) == 5 && ($key == (count($product_invoice)) - 1)) { ?> style="height:110px;"<?php } ?>
<?php if (count($product_invoice) == 6 && ($key == (count($product_invoice)) - 1)) { ?> style="height:50px;"<?php } ?>
<?php if (count($product_invoice) == 7 && ($key == (count($product_invoice)) - 1)) { ?> style="height:0px;"<?php } ?>
<?php if (count($product_invoice) == 8 && ($key == (count($product_invoice)) - 1)) { ?> style="height:0px;"<?php } ?>
<?php if (count($product_invoice) == 9 && ($key == (count($product_invoice)) - 1)) { ?> style="height:0px;"<?php } ?>
<?php if (count($product_invoice) == 10 && ($key == (count($product_invoice)) - 1)) { ?> style="height:0px;"<?php } ?>>
<?php echo $cnt++; ?></td>
<td><?php echo $value['software_id']; ?></td>
<td><?php echo $value['description']; ?></td>
<td><?php echo $value['qty']; ?></td>
<td colspan="2"><?php echo $value['unit_price']; ?></td>
<td><?php echo $value['total_price']; ?></td>
</tr>
<?php } ?>
</tbody>
</table>
<table width="100%" class="table goods-table" style="margin-bottom: 0; font-size: 13px; padding: 15px 5px; ">
<tbody>
<tr>
<td colspan="2" rowspan="6" style="font-weight: 700;width:70%; padding: 10px 15px;">
<span style="font-weight:700;">Comments: </span>
</td>
<td style="width:15%;height:10px;">Sub Total</td>
<td style="width:25%;height:10px;" colspan="2"><img src="http://i.stack.imgur.com/nGbfO.png" width="8" height="10"> <?php echo $invoice['sub_total']; ?></td>
</tr>
<tr>
<td style="height:10px;">Other</td>
<td style="height:10px;"colspan="2"><img src="http://i.stack.imgur.com/nGbfO.png" width="8" height="10"> <?php echo $invoice['other']; ?></td>
</tr>
<tr>
<td style="height:10px;">VAT</td>
<td style="height:10px;" colspan="2"><img src="http://i.stack.imgur.com/nGbfO.png" width="8" height="10"> <?php echo $invoice['vat']; ?></td>
</tr>
<tr >
<td style="font-weight: 700;height:10px;font-size: 14px;">Grand Total</td>
<td style="font-weight: 700;height:10px;" colspan="2"><img src="http://i.stack.imgur.com/nGbfO.png" width="8" height="10"> <?php echo $invoice['total_price']; ?></td>
</tr>
<tr>
<td style="height:10px;">Mode Of Payment</td>
<td style="height:10px;" colspan="2"><?php
if ($invoice['paymode_mode'] == 1) {
echo 'Cash';
}
if ($invoice['paymode_mode'] == 2) {
echo 'Cheque';
}
if ($invoice['paymode_mode'] == 3) {
echo 'Cash and Cheque';
}
?></td>
</tr>
<tr>
<td colspan="3" >In Words: <?php echo ucwords(convert_number_to_words($invoice['total_price'])); ?> Rupees Only</td>
</tr>
<tr>
<td colspan="2">Installation Done<br>
<br><br><br>
Receiver's Signature with Seal
</td>
<td style="text-align: center;" colspan="3"><span style="font-weight: 700;font-size: 14px;">For </span><span style="font-weight: 700;font-size: 14px;">oft</span>
<?php if ($seg == "preview") {
?>
<img src="<?php echo IMAGE_PATH_BACKEND; ?>test.png" style="margin: 0 auto;display: block;" class="text-center" alt="logo"/>
<?php
} else {
?>
<img src="http://example.com/images/backend/test.png" style="margin: 0 auto;display: block;" class="text-center" alt="logo"/>
<?php } ?>
Authorized Signatory
</td>
</tr>
</tbody>
</table>
<table width="100%" class="table " style="margin-bottom: 0; font-size: 13px; border-bottom: 2px solid #000; border-left: 2px solid #000; border-right: 2px solid #000;">
<tbody>
<tr>
<td style="border-right: 2px solid #000;font-weight: 700;width: 100px;">Branches</td>
<td style="border-right: 2px solid #000;font-weight: 700;text-align: center;width: 100px;">sddsa</td>
<td style="border-right: 2px solid #000;font-weight: 700;text-align: center;width: 100px;">ewew</td>
<td style="border-right: 2px solid #000;font-weight: 700;text-align: center;width: 132px;">ewewq</td>
</tr>
<tr>
<td colspan="5" style="border : 2px solid #000;text-align: center;"><span style="font-weight:700;font-size: 13px;">Note: Computer generated Invoice and requires no signature.</span><br></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
There's a bug in Dompdf (current release 0.8.0) where styling an image with auto margins will cause it to no longer take up any vertical space in the layout.
Luckily your layout is such that working around the issue is fairly simple. Change the code around your image to the following:
<div class="text-center">
<?php
$seg = $this->uri->segment(2);
if ($seg == "preview") {
?>
<img src="http://www.example.com/images/backend/logo_pdf.png" width="380px" height="76px" alt="logo"/>
<?php
} else {
?>
<img src="http://www.example.com/images/backend/logo_pdf.png" width="380px" height="76px" class="text-center" alt="logo"/>
<?php } ?>
</div>
Also of note: don't modify the display styling of images. Currently dompdf requires a special styling to render these correctly and if you change the styling (e.g. to display: block;) you may get unexpected results.
I have a transactional email which resides here:
System > Transactional Emails > Shipment Update
Here is what is inside of Shipment Update:
{{block type="core/template" template="email/header.phtml"}}
<h1 style="font-size:22px; font-weight:normal; line-height:22px; margin:0 0 11px 0;">Dear {{htmlescape var=$order.getCustomerName()}},</h1>
<p style="font-size:12px; line-height:16px; margin:0 0 10px 0;">
Your order # {{var order.increment_id}} has been shipped and now has a status of <strong>{{var order.getStatusLabel()}}</strong>.
</p>
<p style="font-size:12px; line-height:16px; margin:0 0 10px 0;">You can check the status of your order by
Find tracking here.
<p style="font-size:12px; line-height:16px; margin:0 0 10px 0;">{{var comment}}</p>
<p style="font-size:12px; line-height:16px; margin:0 0 10px 0;">
{{layout handle="sales_email_order_shipment_items" shipment=$shipment order=$order}}
</p>
<p style="font-size:12px; line-height:16px; margin:0 0 10px 0;">
{{block type='core/template' area='frontend' template='email/order/shipment/track.phtml' shipment=$shipment order=$order}}
</p>
<p style="font-size:12px; line-height:16px; margin:0;">
If you have any questions, please feel free to contact us at
{{config path='trans_email/ident_support/email'}}
or by phone at {{config path='general/store_information/phone'}}.
</p>
{{block type="core/template" template="email/footer.phtml"}}
I have a block type and file which correlates with the email above and it's located here: /email/order/shipment/track.phtml
<?php $_shipment=$this->getShipment() ?>
<?php $_order=$this->getOrder() ?>
<?php if ($_shipment && $_order && $_shipment->getAllTracks()): ?>
<table cellspacing="0" cellpadding="0" border="0" width="650" style="border:1px solid #EAEAEA;">
<thead>
<tr>
<th align="left" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px"><?php echo $this->__('Shipped By') ?></th>
<th align="center" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px"><?php echo $this->__('Tracking Number') ?></th>
<th align="center" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px"><?php echo $this->__('Tracking URL') ?></th>
</tr>
</thead>
<tbody>
<?php $i=0; foreach ($_shipment->getAllTracks() as $_item): $i++ ?>
<tr <?php echo $i%2?'bgcolor="#F6F6F6"':'' ?>>
<td align="left" valign="top" style="padding:3px 9px"><?php echo $this->escapeHtml($_item->getTitle()) ?></td>
<td align="center" valign="top" style="padding:3px 9px"><?php echo $this->escapeHtml($_item->getNumber());//getConsignmentNumber()) ?></td>
<?php $trackUrl = "https://mystore.narvar.com/mystore/tracking/fedex?tracking_numbers=";?>
<td align="center" valign="top" style="padding:3px 9px"><?php echo $trackUrl. $_item->getNumber();?></td> </tr>
<?php endforeach ?>
</tbody>
</table>
<?php endif; ?>
I store the track_number in our DB. Please see image below.
My question is how do i set my variables in the on the end of this URL which will be going to a third party site.
Find tracking here.
Try this:
$order = $this->getData('order');
As written in http://www.webspeaks.in/2011/06/customize-new-order-email-template-in-magento.html