Emogrifier删除页面上的所有内容

时间:2019-02-14 11:46:20

标签: php html css

我正在尝试使Emogrifier可以与我的页面一起使用,但是由于我是Emogrifier的新手,因此很难使其正常工作。我遵循了github文档,但是不确定如何执行和使用它,因此我只是将给定的代码插入到我的.php文件中:

<?php 
$html = '<button id="updatecv" name="updatecv" class="cvupdater">Opdater CV</button>';
$css = 'cvupdater {margin-left:auto;margin-right:auto;margin-bottom:20px;display:block;width:150px;}';
$emogrifier = new \Pelago\Emogrifier($html, $css);

?>

<?php
try {
    require "config.php";
    require "common.php";
    $id = $_GET['cvid'];
    $connection = new PDO($dsn, $username, $password, $options);
    $sql = "SELECT * FROM cvs WHERE id = :cvid";
    $statement = $connection->prepare($sql);
    $statement->bindParam(':cvid', $id, PDO::PARAM_STR);
    $statement->execute();
    $result = $statement->fetchAll();
}
catch(PDOException $error) {
    echo $sql . "<br>" . $error->getMessage();
}
?>

<?php include "header.php"; ?>

<p class="hidden" id="hiddencvid"><?php echo $id ?></p>



<button id="updatecv" name="updatecv" class="cvupdater">Opdater CV</button>
<p class="cvupdater" style="width:500px;">Tryk på tekst for at redigere. Tryk på "Opdater CV" for at gemme ændringer.</p>

<a href="index.php">Hjem</a>

<div class="cvpreview">

<?php foreach($result as $row) { ?>


<div class="cvheader">
  <div id="img-wrapper">
    <img src="uploads/<?php echo escape($row["cvid"]) . ".png" ?>" alt="profile_picture">
  </div>
  <h1><?php echo escape($row["fullname"])?></h1>
  <div contenteditable class="cvheader-worktitle" id="worktitle"><?php $decodedworktitle = html_entity_decode($row["worktitle"]); echo $decodedworktitle?></div>
</div>

<hr>

<div class="cvbody">
    <div class="leftcolumn">
      <div class="profil columnboxleft">
        <h5>Profil</h5>
        <div contenteditable class="cvtext" id="profiledesc"><?php $decodedprofiledesc = html_entity_decode($row["profiledesc"]); echo $decodedprofiledesc?></div>
      </div>   
      <div class="workexperience columnboxleft">
        <h5>Arbejdserfaring</h5>  
        <div contenteditable class="cvtext" id="workexperience"><?php $decodedworkexperience = html_entity_decode($row["workexperience"]); echo $decodedworkexperience?></div>  
      </div>
      <div class="education columnboxleft">
        <h5>Uddannelse</h5>
        <div contenteditable class="cvtext" id="education"><?php $decodededucation = html_entity_decode($row["education"]); echo $decodededucation?></div>  
      </div>
    </div>

    <div class="rightcolumn">
      <div class="details columnboxright">
        <h5>Detaljer</h5>
        <div contenteditable class="cvtext" id="phonenumber"><?php $decodedphonenumber = html_entity_decode($row["phonenumber"]); echo $decodedphonenumber?></div>
        <div contenteditable class="cvtext" id="email"><?php $decodedemail = html_entity_decode($row["email"]); echo $decodedemail?></div>
        <div contenteditable class="cvtext" id="birthdate"><?php $decodedbirthdate = html_entity_decode($row["birthdate"]); echo $decodedbirthdate?></div>
      </div>
      <div class="skills columnboxright">
        <h5>Evner</h5>
        <div contenteditable class="cvtext" id="skills"><?php $decodedskills = html_entity_decode($row["skills"]); echo $decodedskills?></div>
      </div>
      <div class="languages columnboxright">
        <h5>Sprog</h5>
        <div contenteditable class="cvtext" id="languages"><?php $decodedlanguages = html_entity_decode($row["languages"]); echo $decodedlanguages?></div>
      </div>
    </div>
<?php } ?>
</div>

</div>
<?php include "footer.php"; ?>

但是,无论我在什么地方插入防潮器代码,该代码段之后的内容都会从我的页面中完全删除。

将代码段放置在文件底部确实可以使页面呈现出来,但是emogrifier的功能似乎并不适用。

0 个答案:

没有答案