Welcome Guest, Not a member yet? Register   Sign In
anchor
#1

[eluser]davy_yg[/eluser]
Hello,

I am trying to make this anchor link works, how? Currently, the image does not appears (the image should link to views/connection.php).

views/homepage.php

Code:
<!DOCTYPE html>
    &lt;html lang="en"&gt;
    &lt;head&gt;
    &lt;link href= "&lt;?php echo $style; ?&gt;" rel="stylesheet" type="text/css" media="screen"&gt;
    &lt;/head&gt;
    &lt;body&gt;
    <div id="products">
    <a href="connection.php"><img src="&lt;?php echo $connection; ?&gt;"></a>
    <a href="collaboration.php"><img src="&lt;?php echo $collaboration ?&gt;"></a>
    <a href="solution.php"><img src="&lt;?php echo $solution ?&gt;"></a>
    </div>
    #assumed you want to link to a controller called "Connection"
    &lt;?php echo anchor('page/connection', '<img src="&lt;?php echo $connection; ?&gt;">') ?&gt;;
    &lt;/body&gt;
    &lt;/html&gt;

controllers/page.php

Code:
&lt;?php
    class Page extends CI_Controller {
    public function __construct(){
    parent::__construct();
    ## load the url helper object
    $this->load->helper("url");
    }

    public function index()
    {
    ## define the location of your css directory in reference to the application directory
    $data['style'] = base_url().'assets/css/style.css';
    $data['connection'] = base_url().'assets/images/connection.jpg';
    $data['collaboration'] = base_url().'assets/images/collaboration.jpg';
    $data['solution'] = base_url().'assets/images/solution.jpg';
    $this->load->view('homepage', $data);
    }

    public function connection()
    {
    $this->load->view('connection');
    }

    public function collaboration()
    {
    $this->load->view('collaboration');
    }

    public function solution()
    {
    $this->load->view('solution');
    }

    }
#2

[eluser]jairoh_[/eluser]
try changing
Code:
&lt;?php echo anchor('page/connection', '<img src="&lt;?php echo $connection; ?&gt;">') ?&gt;;
into
Code:
&lt;?php echo anchor('page/connection', '<img src="$connection">') ?&gt;;
#3

[eluser]CroNiX[/eluser]
@jairoh_, what would that do exactly?

@davy_yg - You can't access anything within /system or /application from the URL. Like, you can't go directly to www.yoursite.com/application/views/some_file.php

You should have something like:
/application
/assets
--/css
--/js
--/images
/system
index.php

Then your $data['connection'] = base_url().'assets/images/connection.jpg'; will work properly




Theme © iAndrew 2016 - Forum software by © MyBB