【发布时间】:2014-06-04 17:47:10
【问题描述】:
我找到了一个“HTML5 WYSISYG Inline Editor”,我在我的本地主机上运行它(Ubuntu 14.04)。
这样做的目的是将其嵌入我的网站,并将其用作我网站的主要写作工具。我需要能够选择文件名或让它在文件名的空白处添加-。
这是我为保存其内容而编写的代码
(CodePen from original author: HTML5 WYSISYG Inline Editor)
inline.php
<form action="effe.php" method="post">
<input type="text" name="author" value="" placeholder="Author">
<input type="text" name="header" value="" placeholder="header">
<input type="datetime" name="datetime" value="" placeholder="datetime">
<div id='editor' contenteditable contextmenu="mymenu" name='editor'>
<p>This is just some example text to start us off</p>
</div>
<div class="tags">
<input type="text" name="" value="" placeholder="tag">
<input type="text" name="" value="" placeholder="tag">
<input type="text" name="" value="" placeholder="tag">
</div>
<input type="submit" value="Submit">
</form>
保存.php
<?php
if (!empty($_POST))
{
foreach ( $_POST as $key => $value )
{
if ( ( !is_string($value) && !is_numeric($value) ) || !is_string($key) )
continue;
?>
<?php echo htmlspecialchars( (string)$key ); ?>
<div class="article-meta">
<a class="author" rel="author" title="author" href="/about" target="_blank"><?php echo "$author";?></a>
<time datetime="<?php echo "$datetime";?>" title="<?php echo "$datetime";?>"><?php echo "$datetime";?></time>
</div>
<h1><?php echo "$header"; ?></h1>
<?php echo "$editor"; ?>
<div class="tags">
<span> <?php echo "$tag1"; ?> </span>
<span> <?php echo "$tag2"; ?> </span>
<span> <?php echo "$tag3"; ?> </span>
</div>
<?php
}
}
?>
结果:
我已经度过了美好的一天,只是没有看到做错了什么。请注意,我的php 知识非常基础。
我知道使用db 是一种选择,但在我的脑海中,我只在过去一两年写过类似20+ 的文章。当我达到 100 篇文章时,我会考虑切换到数据库。
【问题讨论】:
标签: javascript php html editor inline