I know how to display default view in Code Igniter. But, how can I access other files inside view folder. Example I want to display 'application/views/admin/index.php' but it isn't default view.
You can add sub folders in view like so.
$this->load->view('admin/index');
Is that what your meaning.
Codeigniter Views
File name: Example.php
<?php
class Example extends CI_Controller {
public function index() {
$this->load->view('admin/index');
}
}
Folder Structure
application
application / views /
application / views / admin
application / views / admin / index.php
I would not choose index.php for a name for a view I would rename it to another name dashboard.php or some thing. Because you have a index.php in the main directory.
Related
I am using Laravel 4.2 and I having a problem with including sub-views.
I have a folder called 'header' in my views and header.php in that folder. Looks like this:
/app/views/header/header.php
I have already dump-autoloaded the project directory.
In my view (index.php), I have
#include('header.header')
What am I missing?
You should use .blade.php extension to your view, in order using partial views..
You need the blade extension on your index.php file
index.blade.php
Hi there i have some stupid mistake in configuring laravel.
First of all, this is my structure of folder
i use shared-hosting service and i place my laravel app, vendor and bootstrap into lib folder outside the htdocs (public/public_html) folder
so basically:
var
public_html
www
lib
-app
-bootstrap
-vendor
i create two subdomain called console for client and panel for admin
so i could call the subdomain specific url to access the system
this two subdomain is placed inside the public_html
public_html
-console
-panel
Then i move the public folder from laravel original into console folder (subdomain) with all the content from public folder (index.php, .htaccess, etc.)
Console.myDomain.com is working perfectly.
Now i want to create the admin system from the panel.myDomain.com i have created the subdomain and place all assets files (css, js, etc.) and change the routes into:
Route::group(array('domain' => 'panel.myDomain.com'), function(){
Route::get('/', function()
{
return View::make('admin.index');
});
});
but the page only showing blank page, (the blank page is shown because i place index.php file without content inside the panel folder)
additional info i have setup the bootstrap/paths.php into 'public' => __DIR__.'/../../public_html/console'
and is it require to change?
what proper way to make the panel.myDomain.com execute the routes and showing the right blade i have made?
thank you.
I am using rails 3.2.12 version.
I want to embed HTML5 game in my static web page (game.html.erb).
I am confuse about what will be the src of Iframe tag?
I am using
<pre>
iframe src="index.html" height="460" width="500"
</pre>
in game.html.erb page
but error occurs
NO ROUTE MATCHES GET "/static_pages/index.html"
I have put game file index.html in same folder as game.html.erb.
what is issue?
If the html is static then just move the html file into the '/public' folder of your rails app and change the src for the iframe to be "/index.html"
If you don't want to put it into the public folder, you'll need to either add an action to the controller that your game.html.erb is rendered from or create a separate controller for the static html.
Based on what your question states though, I would put it into the public folder as it is just static html and wouldn't require a controller.
The problem with the setup you have is that your index.html file is just a static file, where the view folder that contains game.html.erb relates to a controller and is rendered from an action in the controller. Static files don't get rendered from that folder. The public folder contains static files and folders that you want on the root of your site (except for javascript, images and css which go in the asset pipeline).
I have no idea why this error is occurring after debugging the project even though the codes are default.
Controller
public class HomeController : Controller
{
//
// GET: /Home/
public ActionResult Index()
{
return View();
}
}
View
#{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<title>Index</title>
</head>
<body>
<div>
Hi
</div>
</body>
Somehow or rather, after debugging, the Requested URL is always /Views/Home/Index.cshtml but accessing Home via browser is fine. (http://localhost:58323/home)
I googled and solution hints that the problem lies in global. But thats weird, I dont remember making any changes to it.
Global
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
}
Appreciate any help. Thank you
I think you just have your visual studio settings set so that the view is set to the start page. Right click on the project and go to properties, then to the web tab. Is the 'specific page' radio button selected with 'Views/Home/Index.cshtml' set as the value? Change it to use a start url. Personally I prefer not to have the debugger start up a browser and use Don't open a page.
Right click your web project -> Properties -> Web
check that you have the start action set to Specific Page with no value in the field.
My guess is that you have the start action set to current page.
This error might even cause if the hierarchy of the folder structure is incorrect in Views folder.
If you are adding views by right-click on Views folder.The new view added might be incorrectly placed in the folder hierarchy.
The way to troubleshoot the problem is:
Consider a view named index.ascx which is supposed to be linked to a Controller named HomeController.
Under the Views folder there should be a folder name Home (relating to the Controller) and the
index.ascx should reside in Home folder.
The best possible way to add view is to right-click just beside the public method which will show a Create View option in context-menu.If you crate view in such manner then folder hierarchy is automatically created.
I have two directories within my codeigniter controller.
/controllers/admin/
dashboard.php
content.php
enquiries.php
/controllers/members/
profile.php
chat.php
settings.php
Because the directory folders are not themselves controllers I can't perform any functions if the user browses to the root of the directory.
Example if the user browses to
/localhost/admin/
a view won't be loaded and will not show a 404. This lets users know that the directory does exist, giving me a security risk because people will know that I have an admin directory.
How is it possible to show a 404 message if the user browses to the root of the directory folder???
You could add this in config/routes.php:
$route['admin'] = 'errors/page_missing';
$route['members'] = 'errors/page_missing';
... where Errors is a controller with a method of page_missing, where you load a 'file not found' view.
The way I do it is creating the default controller welcome.php in the directories I wan't to hide and add the show_404() function. Like this:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Welcome extends CI_Controller {
public function index()
{
show_404();
}
}
This way, you don't have to fiddle with routes or rewrite rules. Simple and clean.