CodeIgniter view anchor tag prepending host - codeigniter

In my view I'm trying to create an anchor tag but CodeIgniter is prepending my entire host before what I specify as href, therefor making it invalid.
I put this
My File
I get
My File
EDIT 3
This is my view, I realise i should not be calling a function in my view but in this case I had little option as something needs to get applied for each data item in the loop, I will try to change this but thats beyond my problem right now.
Wesley: I checked the soruce and it displays correctly in the source but in the browser it preappends the host so I guess this has nothing to do with code igniter afterall! How do I make sure it doesn't happen?
<td><?php
$this->ci = &get_instance();
echo $currentData["field_one"] . " - Log"; ?>
</td>
EDIT 4
my html source
<a href="file:://///\\myhost.local.com\120">
View Log
</a>
my url address bar
http://myhost.local.com/myhostlocal/index.php/level/one/type/b/cc/ee/
the url it goes too when I mouse over the href
http:///myhostlocal/index.php/level/one/type/b/cc/ee/file:://///\\myhost.local.com\120

Looks like the browser is treating "file:://///" as a relative path. Why do you have 2 colons, do you need both? Removing one will provide a valid protocol, and the browser will start treating it as an absolute path.

Related

Relative redirecting with or without the trailing slash

Basically the problem I'm facing with my laravel server is very basic, but I somehow still struggle with that. It's all about relative redirecting. Let's say for example, I have following uri: http://testsite.dev/configure. It's returning a view and I have some link there. I'd like to make the link send me to http://testsite.dev/configure/element-2
But if no matter what href I put to the a tag, it always sends me to http://testsite.dev/element-2. I've tried:
<a href="/element-2">
<a href="element-2">
<a href="../element-2">
<a href="/../element-2">
Each time without success. So I finally came up with force putting a trailing slash at the end of the /configure/, but I doubt that's a good solution. Could you suggest the best way to do my relative redirecting? I basically want links to add up to the current url and not to rewrite it. Answer should be somewhere in the htaccess file... Thanks in advance!
You can use the following:
Configure
Configure
all {{ function }} does is echo the function.

Modifying joomla mod_banner to count banner

I'm using default joomla mod_banner.
I'd like to modify the module so can give specific css class for each banner image, so if the module displaying 3 banner images, the first banner (image) will have class="banner1", the second image will have class="banner2" the third image will have class="banner3" and so on.
How can I do that?
If you decide to modify your mod_banners module, then just follow the steps:
Open the /modules from your root directory.
Find the directory named mod_banners in modules/mod_banners
Find out the tmpl directory modules/mod_banners/tmpl
default.php is the file that display the images into the frontend of you joomla website.
just edit this file. See the img tag into and just change whatever name you want to give the class..
UPDATE : Take a look on the given Codes:
// Add variable before
$unique_number = 1;
// Provide the Provides the images URL or related information
foreach($list as $item):
now just find out the <img tag and just add a class something like
<img class='banner-<?php echo $unique_number?>'
and at the end of the file findout the endforeach; and just add the code something like
<?php
$unique_number++;
endforeach;
?>
providing you the class name like banner-1, banner-2, .... etc.
IMPORTANT: If you notice on the top most of your default.php the module provide the images into an array, If you are familiar with the Joomla modules structures then you can modify it easily.

Codeigniter URL for navigation

I can't figure out how to do the url links.
Basically I have my navigation bar, and I don't know which CodeIgniter URL code to use and how to implement it.
Is what I'm doing here right?:
<?php $this->load->helper('url'); ?>
<li>About Us</li>
I tried to do an anchor like this, but when I load the page it just turns up blank:
<?php echo anchor('views/about.html', 'About Us', title='About Us'); ?>
What am I doing wrong?
There are two ways to make links:
CodeIgniter helper style:
<?php echo anchor('about', 'About us', 'title="About us link"'); ?>
More common HTML with URL echo:
About us
Both will output:
About us
Though if I understand what you are trying to achieve, your mistake is elsewhere.
You don't include the views part, as your URL should point to the controller, not a view. The only case is if you have a controller named views.
CodeIgniter is set up so that it doesn't include file extensions like .html in URL's by default. It does if you've set them up in your config file in $config['url_suffix'] = '';, which is null by default.
See if you've made any of these mistakes.
That is another way on how you do the URL if you are using the URL helper in CI. You should try this, make the base_url() as the value for href. Try this,
About Us
You have to try like this
About Us
or you can give like
About Us
and in the "about" function you put
$this->load->view('about');
but i think the firstone will works for you fine.

codeigniter path issue

I am trying to link my view page to another controller.
my test_view.php page
//this page address is base_url/controller1/function1
<a href='controller1/function2'> test </a>
If i click, the page address will be base_url/controller1/function1/controller1/function2 which is not my desire.
my controller
//the first function1 is to show my test_view page
function function1 (){
$this->load->view('test_view');
}
//I can't get to this function2 with the link I used
function function2 (){
$this->load->view('funny');
}
Anyone could help me about this? Thanks a lot.
Sure--you just need to tell CodeIgniter to display the path:
<a href="<?php echo site_url("controller1/function2");?>">
One thing: This displays the absolute path of your site as defined in your config, not the relative path.
I prefer relative paths, so I like to create a universal function called site_path to do the same thing without the absolute URL. I include it in one of my universally loaded libraries and it looks something like this:
function site_path($url) {
return "/$url";
}
The benefit of this is that, if I initially develop the site in a subdirectory, I can set site_path to return "/subdirectory/$url" and then just remove the subdirectory once I launch.
It's linking to a relative URL, you need to start with a '/' to use the web root
<a href='/controller1/function2'> test </a>
you can use following code in test_view.php page,
<a href='<?php echo base_url();?>controller1/function2'> test </a>

how do i link to a specfic block in a page?

I had displayed part of "latest testimonial" (textarea) on my home page, and placed a "view more" link in the end.
Now I want to link to that specific testimonial on a page when "view more" is clicked.
But I had a list of testimonials on a single testimonial page, meaning no separate detail page for each testimonial. So how can I display the specific testimonial on the page ?
<?php echo $this->getUrl('testimonial'); ?>
this gives a link to my testimonial page.
First you need to provide some element IDs on your testimonials page. For example if each testimonial is in a quote:
<blockquote id="testimonial001">
...
</blockquote>
Or place a named anchor just before each testimonial:
<a id="testimonial001"></a>
...
Then your URL can be built with a fragment:
<?php echo $this->getUrl('testimonial', array('_fragment'=>'testimonial001')); ?>
By specifying the ID through a route parameter you will override any other fragment that might get set by another module (don't know which, just know that it can happen) which is preferable to merely appending it.
example below should generate a link this this: http://www.example.com/testimonial#anchor
<?php echo getUrl('testimonial'); ?>#anchor
The rest you can find in this document: http://www.w3schools.com/tags/tag_a.asp
using this example: http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_link_bookmark

Resources