File extension for Laravel Blade as an 'index' page - laravel

My 'homepage' for a Laravel install works great, which is: welcome.blade.php however, my question is - how do I get other basic 'static' pages to work correctly.
My preferred site top level navigation has for example, 'about us', so what I'd like to do is create a directory called 'about us' and then place a similar page as blade.index.php in there but it throws an error.
So, my question is - how do I name the file within a directory within the web application.
Thanks

You've got it flipped. blade always goes in the middle.
index.blade.php
return view('index');
/about/index.blade.php
return view('about.index');

You will need put your view file inside static folder of your choice and make sure your filename should contain blade in the middle for ex: "about.blade.php" and after that you will need to return that file with folder_name/file_name.
return view('Folder_name/File_name');
Try above code you are good to go.

Related

Get the file name BLADE of LARAVEL

is it possible to know which BLADE page you are on? I would like to include a different menu where my VIEW is the MAIN, how can I do this in the template? I check if it is my MAIN and add my different menu there if in case. example: #if(config('page.layout') == 'top-nav');
Is that possible? but with another code, of course
To me it seems like you are thinking with the wrong way. You should know what(which controller, which method) has loaded that view instead of what is this view. And you can pass control variables from there if you want.
In you question, the example you have shown:
#if(config('adminlte.layout') == 'top-nav')
So top-nav is coming form config adminlte.layout which has no relation with blade template or anything else. You can definitely do that if you set your config file based on your intention.
I wanted to pick up which file or URL my BLADE was, I got it this way:
#if(Route::current()->getName() == 'name') ....
##codeHTML
#endif

in laravel view I want the content of the url and not the url itself

I would like to show the content instead of the url in my view. How can I use Laravel to make this work?
At the moment, in my Laravel view I have:
Link
<p>{!! route('plaats.text', ['plaats' => $plaatsje]) !!}</p>
<p>{!! action('TablesController#text', ['plaats' => $plaatsje]) !!}</p>
The first creates a link with a working active url, the second and third a death link: "http://mysecondsite.dev/koop/text/plaats/capelle-aan-den-ijssel".
Following the link itself (in all cases) returns the expected content of the url (So, my routing seems to be ok). But neither returns the underlying content.
regards
Peter
I think what you are looking for is blade service injection
It's bad practice to inject logic into views.
What you probably should do is do the operations before the view, and then pass the results (contents) to the view and echo them

Joomla display view not displaying site template

I am trying to load a view from my controller using the follow code but I only get a raw HTML view and does not show the site's template.
$view = $this->getView( 'download', 'html' );
$view->display();
Can some help me in what I am doing wrong to display the site's template.
I also tried a redirect but that did not work either
$this->redirect(JRoute::_('index.php?option=com_atdwcsv&view=download'), false);
Edit: I figured out what was wrong with the redirect. Code I needed was
$this->setRedirect('index.php?option=com_atdwcsv&view=download');
$this->redirect();
I could be wrong, but I don't think you need to use the display() method on the view, I think you need to use $this->display(); instead.

Laravel 3: View doesn't exist

I've just inherited a Laravel 3 site which works on a custom CMS. The CMS output is rendered through a theme folder at the / level so my folder structure looks like:
-application
-bundles
-laravel
-public
-storage
-theme
-errors
-layouts
-partials
I've made a search controller within '/application/controllers' and I want to create my view for the output in the '/theme/layouts' folder with the other template files. When I've worked with Laravel before, my views are all within '/application/views' and I can specify my view with:
public $layout = 'layouts.default';
..which would use '/application/views/layouts/default.blade.php'
How can I get my controller to render the view using my '/theme/layouts/searchTemplate.php' file and pass in the search data from the controller?
If you really need to put these files in a separate folder you should probably use bundles (see docs).
However, a quick and dirty solution is to add a hook in the view loader event (application/start.php):
Event::listen(View::loader, function($bundle, $view)
{
if($bundle == 'theme') {
return View::file('application', $view, Bundle::path('application').'theme');
}
return View::file($bundle, $view, Bundle::path($bundle).'views');
});
You can then make views like:
View::make('theme::layouts.default');
which will load the file "application/theme/layouts/default.blade.php".
In your application folder, there is a folder called 'views'
You have to create the default.php in applications/views/layouts/
With 'layouts.defaults' it search in the views folder to a folder that will be called layouts.
So the complete folder for 'layouts.default' would be: ./application/views/layouts/default.php
Edit: answer is not relative anymore

How can integrate html template in codeigniter

I'm new to codeigniter. please tell me how can I integrate or install a html theme/template in codeigniter ? (my css folder path=news/css and application folder path=news/application where news is my main folder)
-thanks.
This is a very simple, very powerful way to do templates in codeigniter that is also very flexible.
http://news.dice.com/2013/02/18/how-to-build-a-to-do-app-with-codeigniter/
ignore the title, most of the lesson is about setting up templates in CI.
Note that i was first exposed to this method from a jeffrey way CI tutorial on net.tutsplus.com
All of them are worth checking out: http://net.tutsplus.com/sessions/codeigniter-from-scratch/
edit -- ok this is good enough addition to post. So in the tutorial, on the template.php page, you will see
$this->load->view($maincontent);
which is cool. but this is much better:
// load your header views
$templatefolder = 'beta/';
if(isset($content01))
$this->load->view($templatefolder.$content01);
if(isset($content02))
$this->load->view($templatefolder.$content02);
if(isset($content03))
$this->load->view($templatefolder.$content03);
// load your footer views
so instead of calling the view "maincontent", i've put in references to $content1, $content2, etc. Because we are doing if isset none of them are required. that way you can easily send more then one view file to the template. Or none at all if you are just showing a message, etc. Also notice that we have $templatefolder - that way you can easily reuse the template file for other site templates, even with the same content.
in your controller (similar to tutorial) it would be
$data['content01'] = 'codeigniterrawks';
$data['content02'] = 'mypetlion';
// beta template
$this->load->view( 'template_beta', $data );
note how easy it is if i want to bring in those same view files into a different template
$data['content01'] = 'codeigniterrawks';
$data['content02'] = 'mypetlion';
// alpha template
$this->load->view( 'template_alpha', $data );
I ran into this exact question about a week ago, this guide really helped me:
http://net.tutsplus.com/tutorials/php/an-introduction-to-views-templating-in-codeigniter/
To do the CSS url's, I added "uri" to my libraries in config/autoload.php (so it looks like this:
$autoload['libraries'] = array('uri', 'database');)
" type="text/css" media="screen" />
the base_url function automatically return whatever the base url of your site is, ie
http://localhost/news/
with the argument appended to the end.
The reason behind this is that if/when you ever need to migrate servers, you just change the base_url in the config file and it automatically updates across all of your templates and sources.
Try this,
I'm using this and it's very powerful.
https://github.com/philsturgeon/codeigniter-template

Resources