codeigniter's controller to main controller in a specific div - php

<li>SERVICES</li>
<li>ABOUT</li>
<li>CONTACT</li>
I'm using CodeIgniter and this code was in a different controller. suppose http://localhost/defctrl/function1
I want to return to my homepage "maine/home" in a specific div when you click on the list but the above code doesn't work. neither ../maine/home#services.
How can I solve this problem?

if it's on the same page you can use
<li><a href="#services"
if another page
<li><a href="<?php echo base_url() ?>{route or controller name}#services"
Make sure URL helper is loaded and site load with index.php

Related

How to call .hmtl file inside the header.php in wordpress?

I have finish all my html pages and now I want to add them inside the header.php.
Please see the code below:
<li class="menu-item"> AboutUs </li>
As you can see Iam using the_permalink function to call the html file , but when I click in the navbar the aboutus nothing happen , I dont get the aboutus.html.
Can you please tell me how to ge to my point?
You do not output anything from PHP. Change <?php to <?=:
<li class="menu-item"> AboutUs </li>
<li class="menu-item"> AboutUs </li>
$location_of_file will contain address to aboutus.html file without slash at the end.

How nav bar works in this php code using codeIgniter?

This is a source code of nav bar made using PHP framework CodeIgniter.I didn't understand login behind nav url of "Bulk Conversion" and "Login" which is given using site_url instead of <a href = "bulk_conversion.php"> and <a href = "login.php">. How nav bar code works here?
<div class="header clearfix">
<nav>
<ul class="nav nav-pills pull-right">
<li role="presentation" class="{{ $_nav === 'batch' ? 'active' : '' }}">Bulk Conversion</li>
<li role="presentation">Login</li>
</ul>
</nav>
CodeIgniter is an object-oriented MVC framework. For the most part you don't make calls to .php files by name. Instead, CodeIgniter uses a segment-based approach to URLs with a one-to-one relationship between a URL string and its corresponding controller/method and optionally, parameters. Any URI segments after the first two are considered parameters (variables) passed to the controller's method. Find a better explanation of what I'm trying to explain in the Documentation.
site_url is a CodeIgniter helper function that will construct a full URL from a URI string. So the call to site_url('batch') for a website on example.com will produce the string http://example.com/batch. This will result in the index() method of the controller Batch being executed.
The call site_url('admin') works the same except the Admin controller is being called.
Clear as mud?

i am trying to get to the root url in php

I have this link in my db.php. I want everytime the dropdown menu is clicked it redirect to the corresponding page.
$ROOT_URL = '192.167.1.67/office/';
I want to go to this root url on the navigation every time i click on the link.
Home
<ul class="dropdown-menu">
<li>Add Product</li>
<li>View Product</li>
<li>Removed Product</li>
</ul>
instead the page is redirecting as
192.168.1.67/admin/192.168.1.67/admin/product/addproduct.php
How can i solve this problem??
use protocol before your url like..
$ROOT_URL = 'http://192.167.1.67/office/';
OR if having https $ROOT_URL = 'https://192.167.1.67/office/';
If the link points to a local location, you can just use / as root.
This, for examples will work:
Home
If $ROOT_URL is dynamic and you want to include the variable, define it as:
$ROOT_URL = '/office/';
Then you can do:
Home
Also, the links in the list
<ul class="dropdown-menu">
<li>Add Product</li>
<li>View Product</li>
<li>Removed Product</li>
</ul>
point to a relative URL, so when your current URL is /office, the links will point to: /office/addproduct.php. But if this navigation is also included on a page where the URL is /some/other/url, this link will point to: /some/other/url/addproduct.php.
Unless you are really sure the HTML with the link will only show at a certain path, try to avoid relative URLs.

how to make working menu tab with laravel 5.4

I am working on Laravel 5.4
I have created a menu, in which three tabs Home, about and contact. When I click on Home then it should be on home page. When click on about, it should be on about page....
web.php:
<?php
Route::get('/', function()
{
return View('method1.home');
});
Route::get('about', function()
{
return View('method1.about');
});
**method1 is folder in resources\views**
home.blade.php:
#extends('method1.dashboard')
#section('content')
<h1>This is home page</h1>
#endsection
about.blade.php is:
#extends('method1.dashboard')
#section('content')
<h1>This is about page</h1>
#endsection
dashboard.blade.php is:
#include('method1.includes.menu-header')
menu-header.blade.php is:
<li class="active"> Home</li>
<li> About</li>
But when I click on home or about page. It shows Page is not found.
My laravel projet folder name is admin_laravel. When I run http://localhost/admin_laravel/ then it shows home page and when run http://localhost/admin_laravel/about it shows about page.
But when I click on about menu button then in browser shows link http://localhost/about. Means it is not going with http://localhost/admin_laravel/about and page is not showing.
You are missing something there, For a quick fix you can do this:
<li class="active"> Home</li>
<li> About</li>
You can also give route name and go with route method:
Route::get('about', function()
{
return View('method1.about');
})->name('about');
Then:
<li> About</li>
Here is the details: https://laravel.com/docs/5.2/helpers#method-route
You're hard-coding your URLs. When you have <li>About</li> you're telling your browser to go to the about path from the root of the domain (which is what happens when you prefix your URL with /), which in this case is http://localhost/.
There's a few things you should be doing. First, set the base URL for your project, you can update APP_URL in your .env file
APP_URL=http://localhost/admin_laravel
or the url option in config/app.php.
'url' => env('APP_URL', 'http://localhost/admin_laravel'),
Secondly, when generating URLs in Laravel there are quite a few options. If you're not using named routes, then you should use the url helper method to generate your URLs:
<li>About</li>
That will make sure that your URL is based at the root of your project, rather than the root of the domain. When you use url in conjunction with the correct setting as described above, your URLs will be generated correctly.

codeigniter linking to another page

i am new to codeigniter framework. i am having problem with href link. in my home page i have some menu, that goes to different page. for example in normal php if i want to go Sell Books page then i just put sellBook.php in href link. now in codeigniter how can i do this. do i need write something in controller ?
<li >Home </li>
<li>Buy Books </li>
<li>Sell Books </li>
<li>Books on Demand </li>
<li>Request a Book </li>
<li>About Us </li>
as per MVC pattern each of your url is a controller so:
if you, for example, want to link to
http://www.site.com/users
so the controller will look like:
class Users extends CI_Controller{
function index(){
//do somenthing here
}
function list(){
//list your users
}
}
then in your views linking to that controller is simple:
this will link to your users controller and index() method
this will link to your users controller and list() method
the site_url(); method will helps you finding the right link both if
you are using index.php or not in your urls
<a href="<?php echo base_url() ?>controller_name/function_name">
If you are using mod_rewrite to remove the index.php from the URL, you can write your URL as href="/sellbook" otherwise you will have to include it, such as href="/index.php/sellbook".
This assumes, of course, that you have a properly configured route name sellbook. See http://ellislab.com/codeigniter/user-guide/general/routing.html for details on how to achieve this.
If the links are to other pages on your site, then I think your best bet will be to use the url helper, assuming you're using the standard seo friendly format and not query strings. This way, you don't have to take into consideration whether you'll be using .htaccess or not. For example:
echo anchor('your_controller_name/your_function_name/param_1/param_2', 'Sell Books', 'title="Sell Books"');
// or for your home page
echo anchor('/', 'Home', "title='Home'");
If it's an external link, you can use the same function or just a plain html tag:
echo anchor('http://google.com', 'Google Me', 'title="Google Me"');
// OR
<a href="http://google.com" title="Google Me" >Google Me</a>
Note: make sure you load your url_helper in your controller if you'll be using the anchor function:
$this->load->helper('url')
// or add to autoload.php
You can also do it the way #sbaaaang suggested.
Account Details
You can use like this
<li>Home</li>
<li>Buy Books </li>
<li>Sell Books </li>
<li>Books on Demand </li>
<li>Request a Book </li>
<li>About Us </li>
//use
site_url in link with controller name and method
and
$this->load->view('page_name');

Categories