Part of the EllisLab Network
   
 
URL Behaviour?
Posted: 24 November 2006 05:41 AM   [ Ignore ]  
Summer Student
Total Posts:  28
Joined  11-23-2006

Hi!

I’m just new in using and MVC and Code Igniter. I’m having problems with how CI manipulate my links.

http://www.site.com/CIFolder/index.php or
http://www.site.com/CIFolder/index.php/home/

once im in that URL and hover to my contact page I get this result.

http://www.site.com/CIFolder/index.php/home/contact/ <- depending on my href="contact/"

How can I get my expected URL w/o repeating

index.php/home/index.php/home/

if my

href="index.php/home/"

once my address bar has been set with segments like

index.php/home/

and hover to my other links like contact w/c has a href=“index.php/contact/” or href=“contact/” i get this to results:

http://www.site.com/index.php/home/index.php/contact/

and

http://www.site.com/index.php/home/contact/

Profile
 
 
Posted: 24 November 2006 06:38 AM   [ Ignore ]   [ # 1 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  481
Joined  03-08-2006

You’re base_url array index in the config.php file has to be absolute including http, Eg. http://www.site.com/CIFolder/.

 Signature 

Flickr | Last.fm | Del.icio.us

Profile
 
 
Posted: 24 November 2006 06:45 AM   [ Ignore ]   [ # 2 ]  
Summer Student
Total Posts:  28
Joined  11-23-2006

yup my base_url() is already like that.

just now, I have found a solution to my problem.
for some reason I think I got the solution to my problem hehehe! thanks to a well documented user guide.

here’s the solution to my problem:

/*instead of directly: (this is the one causing link problem)
this will result repeated segments because it will get your URL in your address bar and add the href you place in your links like this one.*/
<a href="home/ [u]or[/u] index.php/home/" class="home">home</a>

/*I have use the site_url() function as I applied it to my other links.
On the href in my links.*/
<a href="<?php echo site_url("home/"); ?>" class="home">home</a>

Profile
 
 
Posted: 24 November 2006 06:52 AM   [ Ignore ]   [ # 3 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  481
Joined  03-08-2006

Yes, site_url() is a good option to use as well grin

 Signature 

Flickr | Last.fm | Del.icio.us

Profile
 
 
Posted: 24 November 2006 01:25 PM   [ Ignore ]   [ # 4 ]  
Administrator
Avatar
RankRankRankRankRankRank
Total Posts:  6762
Joined  03-23-2006

Also, don’t neglect the anchor() function.

 Signature 

DerekAllard.com - CodeIgniter, ExpressionEngine, and the World of Web Design
BambooInvoice - Open Source, CodeIgniter powered invoicing.

Profile
MSG
 
 
Posted: 27 November 2006 03:56 AM   [ Ignore ]   [ # 5 ]  
Summer Student
Total Posts:  28
Joined  11-23-2006
Derek Allard - 24 November 2006 01:25 PM

Also, don’t neglect the anchor() function.

anchor() function return me back to my first problem. After clicking mg anchor() my URL is now ....index.php/home and when I click or hover to the home link with anchor function applied my URL again changes to ...index.php/home/index.php/home….

because I have 5 views and 5 controllers,...

sorry I’m just new to CI.

Profile
 
 
Posted: 27 November 2006 04:11 AM   [ Ignore ]   [ # 6 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  481
Joined  03-08-2006

What is the code you are using - could you give us an example where you use anchor()?

 Signature 

Flickr | Last.fm | Del.icio.us

Profile
 
 
Posted: 27 November 2006 06:58 AM   [ Ignore ]   [ # 7 ]  
Administrator
Avatar
RankRankRankRankRankRank
Total Posts:  6762
Joined  03-23-2006

Yeah, as Craig said, show us your use of anchor.  Also, make sure it doesn’t have a “/” in front of the controller name.

anchor ('home/about'); // this is correct
anchor ('/home/about'); // this is incorrect

 Signature 

DerekAllard.com - CodeIgniter, ExpressionEngine, and the World of Web Design
BambooInvoice - Open Source, CodeIgniter powered invoicing.

Profile
MSG
 
 
Posted: 28 November 2006 12:21 AM   [ Ignore ]   [ # 8 ]  
Summer Student
Total Posts:  28
Joined  11-23-2006

Hehehe I’ve finally understand how anchor function works! thanks to you guys.

Here’s the code:

<?=anchor ('home/','home')?>

anyway guys how do I implement my specific style for my anchor like a class and an ID from my CSS Files?

Profile
 
 
Posted: 28 November 2006 12:25 AM   [ Ignore ]   [ # 9 ]  
Administrator
Avatar
RankRankRankRankRankRank
Total Posts:  6762
Joined  03-23-2006

it’s outlined pretty well in the user guide.

anchor(uri segments, text, attributes)

So

<?=anchor ('home','home', array('class' => 'menulink'))?>

Also, you don’t need, and probably don’t want that “/” after home.

 Signature 

DerekAllard.com - CodeIgniter, ExpressionEngine, and the World of Web Design
BambooInvoice - Open Source, CodeIgniter powered invoicing.

Profile
MSG
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 719, on June 06, 2008 10:16 AM
Total Registered Members: 66431 Total Logged-in Users: 29
Total Topics: 84797 Total Anonymous Users: 2
Total Replies: 455088 Total Guests: 211
Total Posts: 539885    
Members ( View Memberlist )
Newest Members:  GlennJDylan1978X_franbaguasllogocsaturkeyPeter BryanttherendStudioGeorgiaJZeer