Skip to content

Instantly share code, notes, and snippets.

@dsk52
Created January 18, 2017 07:04
Show Gist options
  • Save dsk52/524668a7931353bf05690eab1b631d37 to your computer and use it in GitHub Desktop.
Save dsk52/524668a7931353bf05690eab1b631d37 to your computer and use it in GitHub Desktop.
concrete5で特定のページタイプで著者情報の表示
<?php
/**
* ページの投稿者(所有者)名の取得と表示する
*/
$pageType = $c->getCollectionTypeHandle();
$cp = new Permissions($c);
if ($pageType == 'blog') {
$vo = $c->getVersionObject();
if (is_object($vo)) {
$uID = $vo->getVersionAuthorUserID();
$ui = UserInfo::getByID($uID);
if (is_object($ui) && $ui) { // ページタイプ編集時のエラー回避
$postedUserName = $ui->getAttribute('user_name');
}
}
?>
<p class="p-article__writer">WRITTEN BY:<? if (isset($postedUserName) && $postedUserName) { echo $postedUserName; } ?></p>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment