【问题标题】:Is there ways to show a logo in many pages php?有没有办法在许多页面 php 中显示徽标?
【发布时间】:2019-08-06 00:11:22
【问题描述】:

我已经在 header.php 上写了一个代码 logo/img

但是,当我要刷新时,不想显示徽标。

有解决办法吗?

我使用了 bootstrap 4,简单的 html 和 css。我尝试了很多次,但总是失败。

在任何功能中,徽标已经显示,但在“tambahalternatif”中不想显示

这是我的控制器:

<?php

    class Alternatif extends CI_Controller{

        public function __construct()
        {
            parent::__construct();
            $this->load->model('Alternatif_model');
            $this->load->library('form_validation');

        }

        public function index()
        {

            $data ['judul'] = 'Isi Alternatif';
            $data ['alternatif'] = $this->Alternatif_model->getAllAlternatif();


            if($this->input->post('key')){
                $data['alternatif'] = $this->Alternatif_model->cariDataAlternatif();
            }


            $data['hasil'] = $this->Hitung(); //Manggil fungsi Hitung() 

            $this->load->view('templates/header',$data);
            $this->load->view('alternatif/index', $data);
            $this->load->view('templates/footer' );

        }


        public function tambahalternatif()
        {
            $data['judul'] = 'Form Tambah Data Alternatif';


            // $this->form_validation->set_rules('idclient','ID','required|numeric');
            $this->form_validation->set_rules('namaalt','NAMA','required');
            if ($this->form_validation->run() == FALSE) {

            $this->load->view('templates/header', $data);
            $this->load->view('alternatif/tambahalternatif');
            $this->load->view('templates/footer');
        } else {
            $this->Alternatif_model->tambahDataAlternatif();
            $this->session->set_flashdata('flash','Berhasil');
            redirect('alternatif'); 
        }

标题视图

<nav class="navbar navbar-expand-lg navbar-light bg-light navbar-fixed-top ml-right">
<div class="container"><a class="navbar-brand" href="<?=base_url(); ?>" ><img class="logo" src="./img/logo.png" height="28px;" padding="2px 10px;></a>   

我希望图像(徽标)将显示在“tambahalternatif”中,但图像(徽标)仅显示在“alternatif”中

【问题讨论】:

  • 在标头中使用图像src 中的&lt;?=base_url();?&gt;。喜欢&lt;img class="logo" src="&lt;?=base_url();?&gt;img/logo.png" height="28px;" padding="2px 10px;&gt;

标签: php html css codeigniter bootstrap-4


【解决方案1】:

在标题中尝试此代码

<body>
<img src="<?php echo base_url();?>imag/logo.png" height="28px" alt="">  
</body>

【讨论】:

    【解决方案2】:

    使用基础浴而不是绝对路径。

    替换

    <img class="logo" src="./img/logo.png" height="28px;" padding="2px 10px;>
    

    下面一行

    <img class="logo" src="<?php echo base_url(); ?>img/logo.png" height="28px;" padding="2px 10px;>
    

    这样,当您更改视图路径时,徽标的路径将无需更改。

    【讨论】:

      【解决方案3】:
      ***Try this one & let us know is it ok now.
      Thanks.***
      
      <nav class="navbar navbar-expand-lg navbar-light bg-light navbar- 
      fixed-top ml-right">
      
      <div class="container">
      
          <a class="navbar-brand" href="<?= base_url(); ?>" >
              <img class="logo" src="<?= base_url().'img/logo.png'; ?>" 
              height="28px" padding="2px 10px">
          </a>
      
      </div>
      
      </nav>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-12-16
        • 1970-01-01
        • 2018-06-16
        • 2021-04-03
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多