help me with this code.
<< Kembali menghitung
when i click the link it posted double like :
http://localhost/belajarci/index.php/calculator/localhost/belajarci/index.php/calculator
ive tried to remove the href values but the page not refered to the home, its only change another value in my code.
It's right it's redirecting on double url becasue of you need to include $this->load->helper('url') in your file / controller constructor or use url helper in autoload.php
Also do two things in your configuration:
Check the .htaccess file in project becasue may be you have set there any url redirect.
Check in config file for base url what you have set there.
You are getting this URL:
http://localhost/belajarci/index.php/calculator/localhost/belajarci/index.php/calculator
Because you need to include $this->load->helper('url') in your file / controller constructor or use url helper in autoload.php
After loading url helper your URL will work as you need.
You can also follow the CI User Manual: https://codeigniter.com/userguide3/helpers/url_helper.html
Related
I'm trying to put a link in a component's view file (default.php) to another file in the same view (default_formulaire.php) as you can see below:
But I really don't know how to access it in PHP.
I know that the default.php file's url is:
index.php?option=com_multicontact&view=reclamation
but I don't know that of default_formulaire.php.
Thanks for any help :)
The link to any view in Joomla is the following:
index.php?option=com_componentname&view=viewname&layout=layoutname
However, if the layout is omitted from the URL, then it is assumed that it is set to default. So, the following URL:
index.php?option=com_componentname&view=viewname
Will mean that the layout is default, which means that the default.php file will be loaded.
So, in your situation, the URL to load the default_formulaire layout will be:
index.php?option=com_multicontact&view=reclamation&view=default_formulaire
If you need to access a different layout in joomla then you need to add a layout value in joomla url like index.php?option=com_multicontact&view=reclamation&layout=default_formulaire
I am new to CodeIgniter, and I don't know whether this is possible or not. How can I link view to view without the help of controller just like PHP.
{ <a href=''>contact.php</a> }
I tried base_url(), site_url() and current_url() but this error displays:
You don't have permission to access /Buildon/User/views/contact.php on this server.
When your using codeIgniter site url or base url etc. You should send them to the controller.
CodeIgniter Doc's http://www.codeigniter.com/docs
URI Routing: http://www.codeigniter.com/user_guide/general/routing.html
URL Helper: http://www.codeigniter.com/user_guide/helpers/url_helper.html
Lets say
Contact Us
The contact_us in the base_url would be controller name.
Or Example
Example
Example
If you try to send the link to view file will not work.
Incorrect
Example
Copy this file in root of this folder parallel to index.php and then you can access it.
I am new to CodeIgniter and having trouble with link formation. In my page, I have a link to another page set to:
<li>Feed Page</li>
Here the feed is one of my controllers, but the link is showing as:
http://localhost/BusinessPad/localhost/BusinessPad/feed,
which doesn't actually exist. I can't understand how this happened; I have made sure: $config['index_page'] = ''; and I added an .htaccess file. If I leave $config['base_url']='', the base URL is still not working for me.
To deal with anchor tag, You can have like this
Feeds
You shall put the base_url inside your anchor tag and then your controller name.
Then you will get the url like localhost/BusinessPad/feed which you expect.
Note : Make sure you have loaded the url helper by $this->load->helper('url'); or loaded in autoload itself
Feed Page
if this not works use this
Feed Page
Explain :
<?php echo base_url();?>//URL
BusinessPad//Controller
feed//Function
in 1. this will give your site URL. http://localhost/BusinessPad/localhost/. if you host this to live server it will come with tour domain name.
then in 2 it will call your controller which Contains your functions.
Note: if you juct call your controller it will call automatically public function index() if you create.
then in 3 it will redirect to your function which you exactly need.
i'm having an problem with the URL of Codeigniter.
When i use one controller with parameter, example: localhost/ci/products/news (where localhost/ci is the url base), after i click in any element <a />, example: <a href="home"/> Codeigniter redirects for localhost/ci/products/home and no for localhost/ci/home.
Anyone know why this happens?
You must use a base_url for links. Right now your anchor has a relative path in the href="home", you should have full path in your links, when u use mod_rewrite for nice urls.
like
Home
Say for example, I loaded a view from controller1
The url should be index.php/controller1/<function where view is ran>
Then from that view I have a link.
<a href='controller2/view'>View</a>
After clicking that link, the url now looks like this.
index.php/controller1/controller2/view
Is there a way to clear previous url_segment, or is there a better way to link to another controller's function.
Do.
<?=base_url(); ?>/controller2/view
Inside your href.
You can write the link as
<a href='<?=base_url(); ?>controller2/view'>View</a>
remember that you have set the base_url in your config/config.php file
$config['base_url'] = 'http://yourSite';