I'm trying to add a page link in CakePHP using:
<?php echo $html->link('Home', '/notes/index');?>
It doesn't seem to output the proper link.
What I'd want is something like this:
Home
How can I do this?
You'll want to use a url array
<?php echo $html->link('Home', array('controller'=>'notes','action'=>'index')); ?>
This will work for you. You will not be able to use an absolute path :)
Check out the manual page, http://api.cakephp.org/class/html-helper#method-HtmlHelperlink
Create individual controller for this page or create routing for this page in PagesController.
Related
In Codeigniter, I have a database containing a link of a site.
Each item(event) has a link to the event page.
Site
But instead of going to the desired site, it just adds the link to the existing url like this: http://web.site.local/index.php/evenementen/www.referedsite.com
when checking the html code it shows the following:
Site
Does anyone know how to make it go to www.referedsite.com instead of making it add this to the existing link?
You need to put HTTP://
Site
In codeignitor you can use
echo anchor('', 'Site');
// Prints: Site
Read CI Anchor
try
Site
i use php code for call page using url like this
Home
News
Event
etc...
many sample pagination using url
href="news.php?page=$pageno"
my question is how to make link url pagination if using url like
href="?page=news"
i have try using this code
<a href=?page=news?page=$i>$i</a>
but not work, Please help??
i am newbie on php
I think your question is a bit blurry, but try to figure out the logic using the following rudimental code.
In the page where you place your links, enter this:
1
In your news.php:
<?php
if ($_GET['page']) {
// do stuff with $_GET['page'], which is '1' in this case.
}
?>
In this example, $_GET['page'] will evaluate to the number 1. This variable can then be used to include the news you want to display, be it through including another php-page, or by calling a set of articles from a database.
Don't forget to put <?php and ?> tags around the code, otherwise things won't work.
Hi i am new in codeigniter, having trouble with link formation. In my page i have link to another page same to <li>Feed Page</li>
here feed is one of my controller . But the link is showing to me as http://localhost/BusinessPad/localhost/BusinessPad/feed ---that actually doesn't exists. Can't understand how this happen. I have make $config['index_page'] = ''; and add a .htaccess file.
check for value you have assigned to base_url in you config.php file ,try site_url(), change:
<?php base_url('feed');?>
to
<?php echo site_url('feed'); ?>
you can create your own tag and insert a url in the href like this
Link
Or if you want to helper
you can use the URL helper this way to generate an tag
anchor(uri segments, text, attributes)
So... to use it...
<?php echo anchor('controller/function/uri', 'Link', 'class="link-class"') ?>
use this:-
Link
or
Link
or
Link
use this way
Feed Page
or
Feed Page
If you link off the homepage it works. So www.domain.com goes to www.domain.com/parent1/mypage.php but then when I link to the next page it keeps the first segment/parent (right word?) so the link becomes www.domain.com/parent1/parent2/anotherpage.php and so on.
After three clicks we have www.domain.com/parent1/parent2/parent3/third.php. Any idea where I did something wrong. This is also affecting images and all images are appearing as if they are in the category www.domain.com/parent1/images/image.jpg - not sure what the parent1 is there.
I hope that made sense. I am really in trouble here. Any help?
You either want to use base_url as Robert has suggested like this:
Post 123
or you can use site_url() like this:
Post 123
or if you can use the anchor() tag like this:
<?php echo anchor("blog/post/123", "Post 123"); ?>
You're (probably) using relative URI's instead of absolute, that's what is messing it up.
When creating links, it's recommended to use base_url function like this:
echo base_url("blog/post/123");
if you're using it inside a HTML template, just add PHP tags:
<?php echo base_url("blog/post/123"); ?>
You can also use it like this:
Post 123
Hello I am trying to figure out how to make it so when someone clicks a link on my search results it will open in a new window and in the new window have an iframe that displays the url. I am not sure how to go about doing this. I have
$row['url']
that displays the url for each result to use.
To be more specific I am trying to do what filestube does. I like the feature a lot and would like to use something like it on my site. Here is an example url to show you want I mean http://www.filestube.com/5a4c10249bd9fce003e9/go.html
when the link is clicked on filestube it will open a page like this. I have seen lots of sites do this but filestube is what pops in my head right now. Can anyone provide me with a code example or try to explain how to do this? thanks.
You need to redirect to a URL inside of your application, example my_url.php and post to it in parameters the URL you want to show. Than in that script, load an iFrame with that URL.
Example of my_url.php?url=http://www.google.ca:
<div>You Header</div>
<iframe src="<?php $_GET['url']"></iframe>
<div>Your Footer</div>
The link should point to another PHP page. Something like this.
http://www.google.com
In your open-link.php, write your iframe code.
<iframe src="<?=$_GET['url']?>"></iframe>
Assuming you have PHP file named external.php
Make that PHP file accept a $_GET parameter.
Pass the URL as a param
Use that URL to point the iframe in that PHP file to whatever URL is passed