How to fetch title of an item from a database and send it to the header template in CodeIgniter

后端 未结 13 2118
忘掉有多难
忘掉有多难 2021-02-18 19:12

I am writing an application in CodeIgniter where I specify the </code> meta-tag on every page in every controller which I have managed to send to my header te <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-5408099190056760" data-ad-slot="7305827575" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> </div> <div class="fly-panel detail-box" id="flyReply"> <fieldset class="layui-elem-field layui-field-title" style="text-align: center;"> <legend>13条回答</legend> </fieldset> <ul class="jieda" id="jieda"> <li data-id="111" class="jieda-daan"> <a name="item-1111111111"></a> <div class="detail-about detail-about-reply"> <a class="fly-avatar" href=""> <img src="https://www.e-learn.cn/qa/data/avatar/000/00/01/small_000000130.jpg" alt=" 再見小時候 "> </a> <div class="fly-detail-user"> <a href="" class="fly-link"> <cite> 再見小時候</cite> </a> <span>(楼主)</span> </div> <div class="detail-hits"> <span>2021-02-18 20:01</span> </div> </div> <div class="detail-body jieda-body photos"> <p> <p>You can create a Base Controller and Extends all you other controller to that base controller.</p> <p>Like this</p> <pre><code><?php class MY_Controller extends CI_Controller { public $data = array(); function __construct() { parent::__construct(); $this->data['errors'] = array(); $this->data['site_name'] = config_item('site_name'); } } </code></pre> <p>Then In Your Controller </p> <pre><code>class Test extends MY_Controller { function __construct() { parent::__construct(); $this->data['meta_title'] = 'Your Title'; } } </code></pre> <p>And in you views access the page title like this:</p> <pre><code>echo("<title>.$site_name.");

提交回复
热议问题