【发布时间】:2016-08-14 18:48:24
【问题描述】:
在我看来,我有一个时事通讯注册。我希望此注册框和链接仅在
时可见a) 用户未登录
b) 用户已登录但尚未订阅
我的视图代码如下所示:
<div id="footer">
<div class="bottom clearfix">
<div class="container">
<div class="row">
<div class="col-lg-4 sitemap clearfix">
<h4>Hulp nodig?</h4>
<a href="#">Wat is</a>
<a href="#">Veelgestelde vragen</a>
<a href="#">Hoe werkt het?</a>
<a href="#">Contacteer ons</a>
</div>
<div class="col-lg-4 follow clearfix">
<h4>Follow us at</h4>
<a href="https://www.facebook.com" target="_blank" class="facebook"><i class="fa fa-facebook-square" aria-hidden="true"></i></a>
<a href="" target="_blank" class="twitter"><i class="fa fa-twitter-square" aria-hidden="true"></i></a>
<a href="https://www.youtube.com" target="_blank" class="youtube"><i class="fa fa-youtube-square" aria-hidden="true"></i></a>
</div>
<div class="col-lg-4 newsletter clearfix">
<h4>Subscribe to newsletter</h4>
<p>
<input type="text" id="mail" placeholder="Mail" />
<a href="#" class="btn btn-newsletter">Send</a>
</p>
</div>
</div>
</div>
</div>
</div>
现在我们有几个控制器文件(Login、Register、User、Dashboard、Home...),它们都有这样的方法:
public function index()
{
$this->is_logged_in();
// Passing Variables
$data['title'] = '';
$data['class'] = 'home';
// Template declaration
$partials = array('head' => '_master/header/head_home', 'navigation' => '_master/header/navigation', 'banner' => 'home/home_banner', 'filter' => 'home/home_filter', 'features' => 'home/home_features', 'content' => 'home/home_content', 'footer' => '_master/footer/footer');
$this->template->load('_master/master', $partials, $data);
}
我需要的是调用我自己定义的方法来检查我的数据库是否用户已经订阅了时事通讯。并基于该布尔结果显示输入字段与否。
如何以最好的方式解决这个问题?
【问题讨论】:
标签: php html codeigniter