Welcome Guest, Not a member yet? Register   Sign In
css in view passed from function
#1

[eluser]coderex[/eluser]
Hi,

My initial view page with the css works fine >

codeigniter/formcontroller which contains load->view->myform.

However if I post to a function in formcontroller >

codeginiter/formcontroller/newfunction and in that function do load->view->myform to go back to myform in case of errors the css doesn't work. If you view source it shows the css and displays the form but the css does not effect the page. Does anyone know how to solve this?

Thanks in advance.

G
#2

[eluser]Nick_MyShuitings[/eluser]
Without more code examples (use the code tags) then it will be impossible to help.
#3

[eluser]coderex[/eluser]
view

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;html &gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;
&lt;title&gt;edit registration&lt;/title&gt;
&lt;link rel="stylesheet" type="text/css" href="&lt;?php base_url()?&gt;css/cssform.css"&gt;

&lt;/head&gt;
&lt;body&gt;
<h3>Edit Details</h3>

&lt;?php
$this->load->helper('form');
$this->load->view('title');

$this->load->view('menu');


?&gt;

<div id="container">
  &lt;!-- p id="fm-intro" required for 'hide optional fields' function --&gt;
  <p id="fm-intro">Fields in <strong>bold</strong> are required.</p>

  &lt;?php   echo validation_errors();

$attributes = array('id' => 'fm-form');

// note form submitter to function edit_details

echo form_open('/formedit/edit_details',$attributes);?&gt;  

  <fieldset>
    <legend>Contact information</legend>
    <div class="fm-req">
      <label for="fm-firstname">First name:</label>
      &lt;input name="firstname" id="fm-firstname"  value="&lt;?php echo $firstname; ?&gt;" type="text" /&gt;
    </div>
    <div class="fm-opt">

          <div class="fm-req">
      <label for="fm-lastname">Last name:</label>
      &lt;input name="lastname" id="fm-lastname"  value="&lt;?php echo $lastname; ?&gt;" type="text" /&gt;
    </div>
    </fieldset>

    <fieldset>
    <legend>Address </legend>
<div class="fm-req">
      <label for="fm-addr">Address:</label>
      &lt;input id="fm-addr" name="address" value="&lt;?php echo $street; ?&gt;" type="text"/&gt;
    </div>
<div class="fm-req">
      <label for="fm-city">City or Town:</label>

      &lt;input id="fm-city" name="town"  value="&lt;?php echo $town; ?&gt;" type="text"/&gt;
    </div>
    <div class="fm-req">
    <label for="fm-state">Country:</label>
    
            &lt;?php echo $country ?&gt;

    
    </div>
    <div class="fm-req">
      <label for="fm-zipcode">Post Code or Zip code:</label>
      &lt;input id="fm-zipcode" name="postcode" type="text" value="&lt;?php echo $postcode; ?&gt;" /&gt;
    </div>
    
    <div class="fm-req">
      <label for="fm-email">Email:</label>
      &lt;input id="fm-email" name="email" value="&lt;?php echo $email; ?&gt;" type="text"/&gt;
    </div>
    
    </fieldset>
    <fieldset>

    <legend>Band / Artist Information</legend>
    
    
<div class="fm-req">
      <label for="fm-url">Band / Artist Name:</label>
      &lt;input id="fm-url" name="artistname" value="&lt;?php echo $artistname; ?&gt;" type="text" /&gt;
    </div>
    
    <div class="fm-opt">
      <label for="fm-style">Style of Music:</label>
     &lt;?php echo $style; ?&gt;
    </div>
    
    <div class="fm-opt">
      <label for="fm-comments">Influences: Artists who you listen to, this will help fans find you </label>

      &lt;textarea name="influences" cols="40" rows="5" id="fm-comments" value=""&gt;&lt;?php echo $influences; ?&gt;&lt;/textarea&gt;
    </div>
    
    
    <div class="fm-opt">
      <label for="fm-comments">About you and your music:</label>

      &lt;textarea name="biography" cols="40" rows="5" id="fm-comments"&gt;&lt;?php echo $biography; ?&gt;&lt;/textarea&gt;
    </div>
    
    <div class="fm-reg">
    <label for="fm-style">
    
    </label>
    
    </fieldset>
    <div id="fm-submit" class="fm-req">
      &lt;input name="Submit" value="Submit" type="submit" /&gt;

    </div>
  &lt;/form&gt;
</div>
&lt;/body&gt;
&lt;/html&gt;

controller

Code:
Controller

&lt;?php

class formedit extends CI_Controller {
            

    function index()
    {
            
        $this->load->model('user_model', '', TRUE);

$data['profile'] = $this->user_model->view_profile();


// load initial view with users data

           $this->load->view('myformedit',$data);
    
            
    }
    
    function edit_details()
    
    {
    $this->load->model('user_model', '', TRUE);
    
    $this->user_model->edit_profile();
    
    $data['profile'] = $this->user_model->view_profile();

// load view again but css does not work
    
           $this->load->view('myformedit',$data);
    
    echo "<b>Your details have been updated</b>";
}
}
#4

[eluser]Nick_MyShuitings[/eluser]
You're not echoing the base url in you view... so when you change paths its no longer finding the css file it seems
#5

[eluser]InsiteFX[/eluser]
With CODE TAGS! he means this:
Code:
// Remove space after code!
[code ]
// your code
[/code ]

application/views/header_view.php
Code:
&lt;head&gt;
// meta data title etc.

&lt;link rel="stylesheet" type="text/css" href="&lt;?php echo base_url();&gt;css/cssform.css">
&lt;/head&gt;

application/views/template_view.php
Code:
&lt;?php $this->load->view('header_view');
&lt;?php $this->load->view('content_view');
&lt;?php $this->load->view('footer_view');

InsiteFX
#6

[eluser]Nick_MyShuitings[/eluser]
Haha... exactly, but I am about 2800 posts away from being able to be so brusque about it. :p
#7

[eluser]InsiteFX[/eluser]
You will be like that when you have to try and help someone when they donot use code tags!

Look at all the qoutes, now go and change everyone of them so that your code looks good!

When all you have to do his either use code tags or click on POST REPLY which is a full editor with links code email etc!

InsiteFX
#8

[eluser]coderex[/eluser]
ok i understand your frustration, I rushed that off a bit, your suggestion did trick

:wow:

Code:
&lt;?php echo base_url();>
#9

[eluser]InsiteFX[/eluser]
@coderex

This was not pointed at you, I was replying to his answer.




Theme © iAndrew 2016 - Forum software by © MyBB