• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
2 Simple Noobie Questions. It won't take long to answer : )

#1
[eluser]dannydefcon[/eluser]
Ok my first question is in regard to Forms. If I have a Form that resides on a website with a URL like this: http://www.example.com/user/login/1 , when I submit the form, the url goes from that to http://www.example.com/user/ . However, I would like to retain those variables "login" and "1". I'm currently using the CodeIgniter's form_open() function. I know I can just use the regular html Form tag but that would mean I would have to write out the entire URL.

That brings me to my next question. Why is it that I have to write out the entire URL when I want to access a file. For example, I want to declare the stylesheet file and Javascript libraries in a View called "Header". The stylesheet and javascripts reside in their own respective folders under the main Application directory...in this Header View, why can't I just do something like this ../css/main.css ? It only works if I type out the entire URL of where the file resides.

Please get back to me. I need to figure out these issues before I move forward.

Thanks,
Dan

#2
[eluser]Giorgio Nordo[/eluser]
Well, I begin to (try to) answer your first question:
- you can extract the last two parts of your uri by using the method $this->uri->segment(n) contained in the URI Class
- after you can send such informations to your form by passing data as usual in CI, that is by means of the $data associative array (see the view topic)
To be more explicative, with refer to your case, have a look ad the following portion of code:

Code:
$x = $this->uri->segment(2);
$y = $this->uri->segment(3);
$data['x'] = $x;
$data['y'] = $y;
$this->load->view('user', $data);

After that, the PHP variables $x and $y will be available inyour view for every possible use.

I hope this can help you.
Giorgio

#3
[eluser]Giorgio Nordo[/eluser]
and now, concerning your second question you can also send as $data variable the complete path of your css and js file.
The simplest way to do it, is to write something like:

Code:
$data['pathcss'] ='your css path';
$data['pathjs'] ='your js path';

after that the php variabiles $pathcss and $pathjs will be automatically available in your view and you can use it for including the relative file as usual.

#4
[eluser]InsiteFX[/eluser]
For css links you can do it like this in your headers:
Code:
<link href="<?php echo base_url();?>css/main.css" rel="stylesheet" type="text/css" />

InsiteFX

#5
[eluser]Giorgio Nordo[/eluser]
Maybe a unique css file doesn't fit the Dan's request.
By reading his post
[quote author="dannydefcon" date="1299425398"] For example, I want to declare the stylesheet file and Javascript libraries in a View called "Header". The stylesheet and javascripts reside in their own respective folders [/quote]
it seems to me that he wants to use different css and js file for each (or group of) view(s).

#6
[eluser]InsiteFX[/eluser]
Then he would be better off downloading one of the Assets Libraries like Phil's.

InsiteFX

#7
[eluser]dannydefcon[/eluser]
Grazie Giorgio per aiuto! Buono soluzione!

And Thanks InsiteFX, That is a perfectly fine solution. Why didn't I think of that? lol


Thanks,
Dan

#8
[eluser]Giorgio Nordo[/eluser]
you're welcome Dan and compliments for your italian! :-)
Giorgio

#9
[eluser]dannydefcon[/eluser]
Non ti preoccupa. Io sono Americano pero mi genitori sono nato a Italia e loro parlano Italiano. Allora, io parlo italiano.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.