【即将关站通知●已关闭注册功能】,倒计时剩余:计算中...

Typecho前台发布文章功能的实现方法


一直很喜欢Typecho博客程序的简洁小巧,用来做一句话博客或者生活博客最适合不过,而对于做一句话博客,实现typecho前台发布的功能就更强大了。博客吧搜索了下,有网友给出了相关教程。

操作步骤:

  • 在当前主题的header.php文件或者index.php文件添加以下代码,实现前台发布表单:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    
    <?php if($this->user->hasLogin()): //判断是否登录 ?>  
        <div class="post"> <!--按个人CSS的更改-->     
            <form action="<?php $this->options->siteUrl(); ?>action/contents-post-edit" method="post" name="write_post">     
                <input type="hidden" id="title" name="title" value="<?php echo date("Y-m-d H:i:s");?>" /><!--以发布时间作标题,把这里的hidden改成text就能自定义标题了-->     
                <p><textarea name="text" cols="100" rows="4" id="text" autocomplete="off" onkeydown='countChar("text","counter");' onkeyup='countChar("text","counter");'></textarea></p><!--输入框-->     
                <input type="hidden" id="allowComment" name="allowComment" value="1" checked="true" /><!--允许评论-->     
                <input type="hidden" name="do" value="publish" /><!--公开,可以无视-->               
                <input type="submit" class="pub" value="Send" />     
            </form>                          
        </div>     
    <?php endif; ?>
  • 文章类型的选择,在</form>前添加代码:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    
        <p>  
            <input type="radio" name="format" id="format-post" value="post" checked="checked">  
                <label for="format-post">微博</label>     
            <input type="radio" name="format" id="format-gallery" value="gallery">  
                <label for="format-gallery">图片</label>     
            <input type="radio" name="format" id="format-video" value="video">  
                <label for="format-video">视频</label>     
            <input type="radio" name="format" id="format-audio" value="audio">  
                <label for="format-audio">音乐</label>  
        </p>
  • 添加随机引导语,不需要可不添加:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    
    <?php 
    	$h2 = array(   
    			'随便说说',   
    			'随时随地分享身边的新鲜事~',   
    			'来,说说你在想什么,做什么',   
    			'来搜狐微博看我',   
    			'嘀咕一下'   
    		);    
    ?>      
    <h2><?php echo $h2[(array_rand($h2))]; ?></h2>
  • 然后保存文件即可,输入表单的美化,自己通过添加CSS样式调整。
收藏 邀请

路过

雷人

握手

鲜花

鸡蛋


最新评论

在线支持
关闭
欢迎来到魔趣吧
如果你有建站技术问题、仿站需求、模板插件修改需求,请联系我们的技术支持!高效率,低价格的帮你搞定!
请认准魔趣吧唯一官网:www.moqu8.com,谨防假冒网站!

一般问题请到【求助区】发帖咨询(免费)!

邮箱咨询:
winkill2012@qq.com

邮箱咨询需注明:资源地址+本站用户名+具体问题,三者缺一不做处理。非本站资源不处理!
在线支持

关于魔趣吧|魔趣建站

魔趣吧,志在打造全国最大的建站资源共享平台。 本站提供海量免费的建站资源,包括WordPress模板、Discuz精仿模板、PHPWind模板、phpcms模板、Discuz精仿插件、帝国cms模板、织梦模板等上万精品模板!同时,提供各种建站素材、JS特效、整站程序源码!
服务中文站长,传播分享精神!建站,就来魔趣吧!!
2015-2024 魔趣吧 ( 豫ICP备2021024354号 )   豫公网安备41030402000182号 百度统计
HTTPS安全认证
|网站地图 | 已运行:天 
温馨提示:本站所有资源、教程、源码,不得用于非法站点及用途,否则,本站将终止提供任何服务! Powered by Discuz! Licensed