【问题标题】:Adding in Module name to template url将模块名称添加到模板 url
【发布时间】:2013-07-24 02:04:45
【问题描述】:

我在我的 codeigniter 应用程序和 PHil Sturgeon 的模板库中使用模块,当我查看模板的源代码时,我试图了解我正在发生这种情况。它在字符串 user 上添加,这是模块的名称。

http://mysite.me/index.php/user/assets/globals/bootstrap/css/bootstrap.min.css

<!--[if gt IE 8]><!--> <html> <!--<![endif]-->

<head>
    <title><?php echo $template['title']; ?></title>

    <!-- Meta -->
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />

    <!-- Bootstrap -->
    <link href="<?php base_url() ?>assets/globals/bootstrap/css/bootstrap.min.css" rel="stylesheet" />


-application
    -themes
        -mytheme
            -views
                -layouts
                    usermanagement_view.php

【问题讨论】:

  • config.php 中的base_urlindex_page 的设置是什么?

标签: php codeigniter


【解决方案1】:

您没有回显 base_url(),即没有在页面上打印它...应该是:

<link href="<?php echo base_url() ?>assets/globals/bootstrap/css/bootstrap.min.css" rel="stylesheet" />

没有它,href 属性会附加到 url 中的段,这就是你得到这个结果的原因。

也许您打算使用短标签 &lt;?= ,它代表 &lt;?php echo。在这种情况下,请不要 - 它们并不总是在 php.ini 中启用,而您备用的 2 个字符在实时部署时可能会很麻烦。

【讨论】:

  • 我可以补充一点,base_url() 还接受一个将添加到末尾的值。所以我会写 而是为了便于阅读。
猜你喜欢
  • 2016-11-16
  • 2011-11-20
  • 1970-01-01
  • 1970-01-01
  • 2018-01-29
  • 2011-11-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多