0

ユーザーがページに 1 回または 1 週間に 1 回しかアクセスできないようなモジュールが既に作成されているとしましょう。

4

1 に答える 1

1

これにはモジュールは必要ないと思います。問題のノードのカスタム テンプレートを作成します。

まず、ページ タイトルでページ テンプレートを作成する機能を追加します。これをテーマの template.php に追加します。

function themename_preprocess_page(&$vars, $hook) {//bofun
  if (isset($vars['node'])) {
  // If the page title is "restricted" the template suggestion will be "page--restricted.tpl.php".
     $vars['theme_hook_suggestions'][] = 'page__'. str_replace(' ', '__', strtolower($vars['node']->title));

  }

}//eofun

テンプレート フォルダーで、page.tpl.php をコピーし、新しいファイルの名前を page--restricted.tpl.php に変更します。新しいファイルを編集します。これをコンテンツを表示する div の先頭に追加します

   <?php if (in_array('Staff', $user->roles) && date('l') == "Wednesday" ): /*only display users who have the user role type of Staff and display only on Wednesday*/ ?>
<div>
The restricted content
</div>
<?php else: echo "<h1 class='title' id='page-title'>Access Denied</h1><br />You are not authorized to access this page."; endif; ?>
于 2012-06-02T17:30:24.753 に答える