• 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[SOLVED] Redirect

#1
Hello,

Can anyone help me fix this navigation so that it could redirect to google analytics website?


views/navigation.php


PHP Code:
    <li><a href="<?php echo site_url('cpages/settings'); ?>"><class="icon icon-th-list"></i> <span>Settings</span></a></li>
            <
li><a href="<?php echo site_url('cpages/googlenalytics'); ?>"><class="icon icon-th-list"></i> <span>Google Analytics</span></a></li


Cpages/googleanalytics.php


PHP Code:
public function googleanalytics() {
        
        
$this->load->view('googleanalytics');
        
    } 



config/routes.php


PHP Code:
$route['cpages/googleanalytics'] = 'cpages/googleanalytics'



Views/googleanalytics.php


PHP Code:
<html>

<!-- <
meta http-equiv="refresh" content="0; URL='https://accounts.google.com/ServiceLogin?elo=1'" /> -->

<
meta http-equiv="refresh" content="0; URL='<?php site_url('https://accounts.google.com/ServiceLogin?elo=1')?>'" />



</
html
" If I looks more intelligence please increase my reputation."
Reply

#2
Forget the whole thing about routing.
Simply put the following code in your navigation.php file:
PHP Code:
echo anchor('https://accounts.google.com/ServiceLogin?elo=1','Google Analytics'); 

In order to use the anchor function, you need to load the url helper. It's a good idea doing that in the config/autoload.php file:
PHP Code:
$autoload['helper'] = array('url'); 

Besides that, if you want to link to URL's within your own website, you don't need to include site_url at all.
This will do:
PHP Code:
echo anchor('cpages/settings','Settings'); 

And you DON'T need a routing if the url itself is good enough.
A line like you have:
PHP Code:
$route['cpages/googleanalytics'] = 'cpages/googleanalytics'
makes no sense at all.

Routing is needed if you want your url to point to a different controller/method.
So this would make sense:
PHP Code:
$route['tools/googleanalytics'] = 'cpages/googleanalytics'
Reply

#3
Hello,

Can anyone help me fix the appearance that appear in the navigation for google analytics navigation tabs?

This is what I try :

views/navigation.php


PHP Code:
<li><a href="<?php echo anchor('https://accounts.google.com/ServiceLogin?elo=1','Google Analytics'); ?>"><class="icon icon-th-list"></i> <span>Google Analytics</span></a></li>

            


This is the original before revision:


PHP Code:
<?php <li><a href="<?php echo site_url('cpages/googlenalytics'); ?>"><class="icon icon-th-list"></i> <span>Google Analytics</span></a></li>  ?>


Can anyone help me fix the code so that I achieve the same result?

Thanks in advance.
" If I looks more intelligence please increase my reputation."
Reply

#4
Will this make clear how you should use the anchor function?
PHP Code:
<?php
  $ga_url 
'https://accounts.google.com/ServiceLogin?elo=1';
 
 $ga_title '<i class="icon icon-th-list"></i> <span>Google Analytics</span>';
?>
<li><?php echo anchor($ga_url,$ga_title);?></li> 

The anchor function builds the <a href="..."> </a> tags for you, so you should not put those around the link yourself.
Just take some time to read the documentation about the anchor function.
Reply

#5
views/navigation.php

PHP Code:
<li><a href="<?php echo anchor('https://accounts.google.com/ServiceLogin?elo=1','Google Analytics'); ?>"><class="icon icon-th-list"></i> <span>Google Analytics</span></a></li


After I click "Google Analytics" then it starts:

http://127.0.0.1/CompanyGiondaCI/index.p...3Ca%20href=

This is the page:

An Error Was Encountered
The URI you submitted has disallowed characters.
" If I looks more intelligence please increase my reputation."
Reply

#6
Of course you get an error. You didn't do anything with the reply I gave you yesterday at 7:30 am.
Reply

#7
Hello Wall!
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#8
(07-31-2016, 06:53 PM)davy_yg Wrote: views/navigation.php

PHP Code:
<li><a href="<?php echo anchor('https://accounts.google.com/ServiceLogin?elo=1','Google Analytics'); ?>"><class="icon icon-th-list"></i> <span>Google Analytics</span></a></li


After I click "Google Analytics" then it starts:

http://127.0.0.1/CompanyGiondaCI/index.p...3Ca%20href=

This is the page:

An Error Was Encountered
The URI you submitted has disallowed characters.

Remember <a href="..., if you use a anchor(...)
Reply

#9
PHP Code:
            <li><a href="<?php echo anchor('www.google.com','Google Analytics'); ?>"><class="icon icon-th-list"></i> <span>Google Analytics</span></a></li


If I click the link, this link appears:  htp://127.0.0.1/CompanyGiondaCI/%3Ca%20href= , I wonder why?  ( I expect it goes to www.google.com)
" If I looks more intelligence please increase my reputation."
Reply

#10
I wonder why you ignore the helpful tips and solutions that other forum members are giving you. You're asking the same questions over and over again. If you don't understand what's wrong with an anchor(..) link between <a href=""> and </a> tags, then you aren't up to working with CodeIgniter yet.
First learn to understand php, html, css and javascript. Now, you're asking how to build a house, but you have no idea what bricks and boards are for. No wonder why the number of replies to your posts is declining. It seems that every minute we spend on helping you, is a waste of time.
I suggest that you lock yourself up for 3 days and spend all the time you have on reading the CI documentation (which is really good!). I don't mean to be rude, but if that doesn't bring you any further, please drop your ambition to become a CI developer.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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