CodeIgniter ile çalışmadan önce bazı ayarların yapılması işlerinizi kolaylaştıracaktır.

baseurl()

bu komut aracılığıyla sitemizde linkleri dinamik hale getiririz. Kullanılabilmesi için
../application/config/autoload.php
dosyasında ilgili bölümü bulup kodu aşağıdaki gibi düzeltmelisiniz.

/*
| -------------------------------------------------------------------
|  Auto-load Helper Files
| -------------------------------------------------------------------
| Prototype:
|
|	$autoload['helper'] = array('url', 'file');
*/
$autoload['helper'] = array('url');

Bu düzeltmeden sonra sitenizin url’sini tanımlamak için
../application/config/config.php
dosyasında ilgili bölümü bulup kodu aşağıdaki gibi düzeltmelisiniz.

/*
|--------------------------------------------------------------------------
| Base Site URL
|--------------------------------------------------------------------------
|
| URL to your CodeIgniter root. Typically this will be your base URL,
| WITH a trailing slash:
|
|	http://example.com/
|
| WARNING: You MUST set this value!
|
| If it is not set, then CodeIgniter will try guess the protocol and path
| your installation, but due to security concerns the hostname will be set
| to $_SERVER['SERVER_ADDR'] if available, or localhost otherwise.
| The auto-detection mechanism exists only for convenience during
| development and MUST NOT be used in production!
|
| If you need to allow multiple domains, remember that this file is still
| a PHP script and you can easily do that on your own.
|
*/
$config['base_url'] = 'http://localhost:8080/';


Bu iki işlemi doğru yaptıysanız; yüklediğiniz ‘url’ helper ile link ve referanslarınızı aşağıdaki gibi yazabilirsiniz.

/*
Bootstrap.min.css stil sayfasını yükle:
*/
<link rel="stylesheet" href="<?php echo base_url("templates/adminlte"); ?>/bower_components/bootstrap/dist/css/bootstrap.min.css">
/*
Resim yükle:
*/

<img src="<?php echo base_url("templates/adminlte"); ?>/dist/img/user2-160x160.jpg" class="img-circle" alt="User Image">
/*
Link oluştur:
*/

<a href="<?php echo base_url("auth/logout"); ?>" class="btn btn-default btn-flat">Çıkış</a>



0 cevaplar

Yorum Yazın

Tartışmaya katılmak ister misiniz?
Katkıda bulunmaktan çekinmeyin!

Bir yanıt yazın

E-posta adresiniz yayınlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir