Welcome Guest, Not a member yet? Register   Sign In
anchor() generates wrong links?
#11

[eluser]mindesign[/eluser]
I'm not using a mod rewrite right now. probably will in the future but what i've tried so far on that hasn't worked all that well.

That's just a temporary base url for when i'm working locally. I will change it to my actual domain once I send it to the production server.
#12

[eluser]brianw1975[/eluser]
hrm... did you try site_url in place of anchor?


Quote:site_url()

Returns your site URL, as specified in your config file. The index.php file (or whatever you have set as your site index_page in your config file) will be added to the URL, as will any URI segments you pass to the function.

You are encouraged to use this function any time you need to generate a local URL so that your pages become more portable in the event your URL changes.

Segments can be optionally passed to the function as a string or an array. Here is a string example:
echo site_url("news/local/123");

The above example would return something like: http://example.com/index.php/news/local/123

Here is an example of segments passed as an array:
$segments = array('news', 'local', '123');

echo site_url($segments);
#13

[eluser]mindesign[/eluser]
Just tried that now. it suffers from the exact same problem. for some reason the index.php in my config file is not being read or something.
#14

[eluser]brianw1975[/eluser]
ok.. last thing i can think of....

do you have a .htaccess file in the same location as index.php? if so, are all of the lines commented out with a #?
#15

[eluser]mindesign[/eluser]
my .htaccess looks like so Cause I need to be able to upload larger files

Code:
php_value upload_max_filesize 10M
php_value post_max_size 10M
php_value max_execution_time 200
php_value max_input_time 200
php_value memory_limit 12M

That is all that's in there
#16

[eluser]TheFuzzy0ne[/eluser]
If the config file wasn't being loaded, CodeIgniter would let you know.

I think that the only possible cause for your problem now is that you're setting $config['index_page'], but you are setting it again somewhere else in the config file or script.

I would highly recommend you run a search for the term "$config['index_page']", and see what comes up in the files you've created/edited.

EDIT: Also, please try this controller, and let us know what the output is:
test_controller.php
Code:
class Test_controller extends Controller {

    function Test_controller()
    {
        parent::Controller();
    }

    function index()
    {
        echo site_url();
    }
}
// End of file: test_controller.php
// Location: ./system/application/controllers/test_controller.php
#17

[eluser]TheFuzzy0ne[/eluser]
Hang on, hang on... I think I know what you're problem might be. Are you actually echoing site_url()? If you are, please could we see the view that's not working?
#18

[eluser]mindesign[/eluser]
I'm not echoing the site_url(), just wanted to use it in <a> but then foudn that the anchor() function should be doing exactly what i wanted to do....but it's always missing the needed index.php from the url if I put anchor("news/allNews","all news")

it does domain.com/news/allNews

instead of

domain.com/index.php/news/allNews

And all my views work like expected. If i use base_url()."index.php/news/allNews" it works perfectly.

:-S
#19

[eluser]TheFuzzy0ne[/eluser]
If you're using it in your view, you will need to echo it.

Code:
<a href="&lt;?php echo site_url('news/allNews'); ?&gt;">All News</a>

It might help both of us if you post your view file. Smile
#20

[eluser]mindesign[/eluser]
My view is this. I am using a template library to include it in a template
Code:
<ul id="newsPosts">
        &lt;?php
        if($verify['available'] == true){
          foreach($news as $row){ ?&gt;
            <ul>
              <li><h1>&lt;?=$row['title']?&gt;</h1></li>
              <li><h2>Posted by &lt;?=$row['user']?&gt; on &lt;?=$row['date']?&gt;</h2></li>
            &lt;?php
              if($row['image'] != ""){
              ?&gt;
                <li class="post_body"><img src="&lt;?=$row['image']?&gt;">&lt;?=$row['text']?&gt;<a href="&lt;?=$row['archive']?&gt;">(read more)</a></li>
              &lt;? }
              else{
                ?&gt;
                <li class="post_body">&lt;? $row['text'];anchor($row['archive'],'(read more)')?&gt;</li>
                &lt;?
              } ?&gt;
            </ul>
        &lt;?php
          }
        }
        else{
          echo $verify['message'];
        }
        ?&gt;
      </ul>

I'm still using the anchor here but I'll make it whatever it needs to be for this to work. thanks for the help so far!




Theme © iAndrew 2016 - Forum software by © MyBB