Skip to main content

bagaimana cara membuat hyperlink?

March 2, 2011 by bobbywa

bobbywa's picture

Kepada yth. rekan - rekan dan para master CI.
saya ingin tanya, kalau membuat hyperlink di html biasa kan seperti ini :

< a href = " http : // localhost / coba " > Coba < / a >

pertanyaan saya :
1. Kalau di CI bagaimana ya?
2. apakah juga perlu ada setting khusus di bagian system/application/ ?

mohon pencerahannya. terima kasih. ^^

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

tanya lagi donk mas

April 5, 2011 by novinaldi, 20 weeks 3 days ago
Comment: 7930

novinaldi's picture

aq pengen link in data yang sama-sama letaknya di view cara nya gmana ya,,kebetulan nama file yang saya buat "data.php" dan aq ingin ke link ke "inputbuku.php".
dah aq buku code nya kayak gini :

 echo anchor('inputbuku') ;">

tapi nggak bsa mas...
mohon donk pencerahannya...

format

March 16, 2011 by cahndeso, 23 weeks 2 days ago
Comment: 7749

cahndeso's picture

format fungsi:

anchor(uri_segments, text, attributes)

contoh :
<?php 
echo anchor(base_url(),"Home");
echo anchor("berita","Berita");
echo anchor("berita/read","Berita",array("title" => "Baca Berita","class" => "red"));
?>

hasilnya adalah:
<a href="http://localhost/">Home</a>
<a href="http://localhost/berita">Berita</a>
<a href="http://localhost/berita/read" title="Baca Berita" class="red">Berita</a> 

penulisan seperti
<?php echo anchor('terms_conditions.php','DISINI')?>

hilangkan .php-nya. menjadi
<?php echo anchor('terms_conditions','DISINI')?>

yang berarti akan memanggil controller Terms_conditions pada funcion index yang disimpan di file terms_conditions.php

Semoga lebih jelas...

Happy Coding...

answ

March 8, 2011 by gungun, 24 weeks 3 days ago
Comment: 7678

gungun's picture

yang term_condition.php itu km taronya di mana y?
dan isi nya seperti apa?

yang term_condition.php itu shrusnya file controller nya..

balas

March 11, 2011 by bobbywa, 24 weeks 19 hours ago
Comment: 7697

bobbywa's picture

saya taruh di view.

di default controller hanya saya tambahkan
$this->load->view('terms_condition');

tanya lagi

March 7, 2011 by bobbywa, 24 weeks 4 days ago
Comment: 7670

bobbywa's picture

saya membuat link seperti ini

Baca peraturannya <?php echo anchor('terms_conditions.php','DISINI')?>

saya sudah setting semuanya, tapi begitu "click" link yg dituju, keluar tulisan :

Object not found!

The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.

If you think this is a server error, please contact the webmaster.

Error 404

localhost
3/8/2011 9:52:19 AM
Apache/2.2.14 (Win32) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l mod_autoindex_color PHP/5.3.1 mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1

Semua nama sudah saya cek, semua sudah sama..tapi kenapa masih seperti ini ya? terima kasih.

BLS:

March 6, 2011 by syabac, 24 weeks 5 days ago
Comment: 7668

syabac's picture

untuk men-generate internal link, menggunakan URL helper.
ada beberapa cara me-load helper.
1. helper di load secara otomatis. edit file /application/config/autoload.php
terus tambah nama helper di bagian helper
2. load secara manual.
http://codeigniter.com/user_guide/general/helpers.html

cara penggunaannya:

 
echo anchor('controller/action/param', 'Text');
//atau
<a href="<?php echo site_url('controller/action/param')? >">Text</a>

dengan URL helper

March 3, 2011 by gungun, 25 weeks 1 day ago
Comment: 7658

gungun's picture

buka config/autoload.php
cari baris berikut!

$autoload['helper'] = array();

lalu load helper url nya dengan memasukan helper url ke dalam array, seperti ini:

$autoload['helper'] = array('url');

untuk membuat hiperlink nya bisa menuliskan seperti ini:

site_url(coba)

atau anchor(coba, Coba)

tapi dengan catatan hanya bisa jalan dalam file.php

jadi di campur dengan html dan php

Premium Drupal Themes by Adaptivethemes