/** * 文章feed * @param string $type 文章类型 * @internal param $null 显示数量由 feed_num决定* 显示数量由 feed_num决定 */ public function listPost($type = 'single') { $PostsList = new PostsLogic(); $post_list = $PostsList->getList(get_opinion('feed_num'), $type, 'post_date desc', true); $RSS = new RSS(get_opinion('title'), '', get_opinion('description'), ''); // 站点标题的链接 foreach ($post_list as $list) { $RSS->addItem($list['post_title'], 'http://' . $_SERVER["SERVER_NAME"] . get_post_url($list), $list['post_content'], $list['post_date']); } $RSS->display(); }
/** * 添加留言 */ public function add() { if (!I('name') || !I('email') || !I('title') || !I('content')) { $this->error('表单未填写完整!'); } else { $post_id = I('post_id'); $post_type = 'page'; // dump(I());die; $data = array('name' => I('name', 'htmlspecialchars'), 'email' => I('email', 'htmlspecialchars'), 'title' => I('title', 'htmlspecialchars'), 'content' => I('content', 'htmlspecialchars'), 'date' => date("Y-m-d H:m:s", time()), 'ip' => get_client_ip(), 'status' => 1); $result = D('guestbook')->add($data); if ($result) { $this->success('留言成功', get_post_url($post_id)); } else { $this->error('留言失败'); } } }
public function widget($args, $instance) { $options = get_mobbr_plugin_options(); if ($options['require_auth'] && !is_user_logged_in()) { return; } if (is_home() && isset($options['button_position']) && $options['button_position'] == MOBBR_BUTTON_POSITION_WIDGET) { return; } global $MOBBR_SUPPORTED_CURRENCIES; $currency = isset($instance["currency"]) && $instance["currency"] && in_array($instance["currency"], $MOBBR_SUPPORTED_CURRENCIES) ? $instance["currency"] : "USD"; $url = get_post_url(); echo "<script type='text/javascript'>mobbr.setLightboxUrl('" . MOBBR_LIGHTBOX_URL . "');</script>"; if ($options['button_style'] == MOBBR_BUTTON_STYLE_CUSTOM) { echo "<button class='mobbr-payment-button' onClick=\"mobbr.makePayment('{$url}')\">{$options['button_text']}</button>"; } else { echo "<script type='text/javascript'>mobbr.button('{$url}', '{$currency}');</script>"; } }
/** * Get translations as linked array * * @return null|array */ public function getTranslationsArray() { $translations = $this->getTranslations(); if (count($translations) > 0) { $list = []; foreach ($translations as $translation) { if ($translation->language == $this->language) { continue; } $t = '<a href="' . get_post_url($translation) . '" title="' . $translation->title . '">'; $t .= $translation->language->name; $t .= '</a>'; $list[] = $t; } return $list; } return null; }
/** * 面包屑 * @param $type * @param string $info * @param string $ul_attr * @param string $li_attr * @param string $separator * @param string $init * @return string */ function get_breadcrumbs($type, $info = '', $ul_attr = ' class="breadcrumbs "', $li_attr = '', $separator = ' <li> >> </li> ', $init = '首页') { $res = '<li><a href = "' . U("/") . '" > ' . $init . '</a></li>'; if ($type == 'cats') { $Cat = D('Cats', 'Logic'); $cat = $Cat->getFather($info); $res .= extra_father($cat, $separator); } elseif ($type == 'tags') { $Tag = D('Tags', 'Logic'); $tag = $Tag->detail($info, false); $res .= $separator . '<li><a href = "' . getTagURLByID($tag['tag_id']) . '">' . $tag['tag_name'] . ' </a ></li> '; } elseif ($type == 'post') { $cat = $info['post_cat'][0]; $res .= $separator . '<li><a href = "' . get_cat_url($cat['cat_id']) . '">' . $cat['cat_name'] . ' </a ></li> '; $res .= $separator . '<li><a href = "' . get_post_url($info) . '">' . $info['post_title'] . ' </a ></li> '; } else { $res .= $separator . '<li>' . $type . '</li>'; } $res .= ''; return $res; }
function get_blog_feed() { $output = false; $posts = get_posts_list('ACTIVE', 'LMOD_DESC'); if ($posts !== false) { $output = '<div class="blog-feed-container">'; foreach ($posts as $post) { $output .= '<article id="excerpt-post-' . $post['id'] . '" class="post-excerpt">'; $output .= '<header class="post-excerpt-header">'; $output .= '<h1 class="post-excerpt-title">'; $output .= '<a href="' . get_site_url() . '/blog/' . $post['url'] . '">' . $post['title'] . '</a></h1>'; $output .= '<div class="post-excerpt-meta">'; $output .= '<p>Posted on: '; $output .= '<strong class="post-excerpt-date">' . $post['date'] . '</strong>, By: '; $output .= '<strong class="post-excerpt-author">'; $output .= '<a href="' . $post['author']['url'] . '">' . $post['author']['name'] . '</a>'; $output .= '</strong></p>'; $output .= '</div>'; $output .= '</header>'; if (!empty($post['excerpt'])) { $output .= '<section class="post-excerpt-content">'; $output .= '<p>' . $post['excerpt'] . '</p>'; $output .= '</section>'; } $output .= '<footer class="post-excerpt-actions">'; $output .= '<p class="post-excerpt-link"><a href="' . get_post_url() . '/blog/' . $post['url'] . '">Read full article.</a></p>'; $output .= '</footer>'; $output .= '</article>'; } $output .= '</div>'; } if (!$output) { $output = '<div class="not-found">Keep in touch, for new articles.</div>'; } echo $output; return; }
<div class="widget-blog-item media"> <div class="pull-left"> <div class="date"> <span class="month"><?php echo gettimestamp($post["post_date"], 'month'); ?> 月</span> <span class="day"><?php echo gettimestamp($post["post_date"], 'day'); ?> 日</span> </div> </div> <div class="media-body"> <a href="<?php echo get_post_url($post); ?> "> <h5><?php echo is_top($post["post_top"]); echo $post["post_title"]; ?> </h5></a> </div> </div><?php } } } ?> </div>