本文整理汇总了PHP中Part::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP Part::exists方法的具体用法?PHP Part::exists怎么用?PHP Part::exists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Part
的用法示例。
在下文中一共展示了Part::exists方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: function
Assets_Package::add('parts')->css(NULL, ADMIN_RESOURCES . 'css/parts.css');
Observer::observe('view_page_edit_plugins_top', function ($page) {
if ($page->loaded()) {
echo View::factory('part/items');
}
});
Observer::observe('controller_before_page_edit', function () {
Assets::package(array('jquery-ui', 'parts'));
});
// Если страницы загружена, загружаем части страниц в качестве виджетов и помещаем
// в блоки с названием частей страниц
Observer::observe('frontpage_found', function ($page) {
$layout = $page->get_layout_object();
$widgets = array();
foreach ($layout->blocks() as $block) {
if (!Part::exists($page, $block)) {
continue;
}
$widgets['part_' . $block] = new Model_Widget_Part($block, Part::get($page, $block));
}
Context::instance()->register_widgets($widgets);
});
// Загрузка JS кода на страницы редактирования
Observer::observe(array('controller_before_page_edit', 'controller_before_page_add'), function () {
Assets::js('controller.parts', ADMIN_RESOURCES . 'js/controller/parts.js', 'global');
});
// Сохранение контента частей страниц
Observer::observe('page_edit_after_save', function ($page) {
$parts = Arr::get(Request::initial()->post(), 'part_content', array());
$indexable_content = '';
foreach ($parts as $id => $content) {
示例2: foreach
<?php
foreach ($pages as $article) {
?>
<item>
<title><?php
echo $article->title();
?>
</title>
<description><![CDATA[<?php
if (Part::exists($article, 'summary')) {
echo Part::content($article, 'summary');
} else {
echo strip_tags(Part::content($article));
}
?>
]]></description>
<pubDate><?php
echo date('r', strtotime($article->published_on));
?>
</pubDate>
<link><?php
echo $article->url();
?>
</link>
<guid><?php
echo $article->url();
?>
</guid>
</item>
<?php
示例3: foreach
foreach ($pages as $page) {
?>
<div class="media">
<a class="pull-left" href="#">
<img class="media-object" data-src="holder.js/220x100">
</a>
<div class="media-body">
<h3 class="media-heading"><?php
echo $page->link();
?>
</h3>
<?php
echo Part::content($page);
?>
<?php
if (Part::exists($page, 'extended')) {
echo $page->link('Continue Reading…');
}
?>
<p class="info">Posted by <?php
echo $page->author();
?>
on <?php
echo $page->date();
?>
</p>
</div>
</div>
<hr />
<?php
}