I have a layouts folder in my resources/views directory and I have a single file named header.blade.php there. The file contains the header of the page and I include the header in each of the page in my application. I have all my required <head> tags in there. What I do in the page is:
#include("layouts.header");
But, I want the title of the header and css <link> tag to be dynamic. So, is there a way I can pass variable with #include() and access the variable in my header page?
Yes, you could use: #include('layouts.header', ['some' => 'data']) and then access the data in the header page with, e.g. $some.
Related
I must show an img html element with src pointing to an image that is originally defined within the resources/images/ folder. So I have written, in my Blade template, the following line (normally it's correct):
<img class="illustration" src="{{ asset('/images/design_7.jpg') }}" alt=""/>
Problem : it doesn't work. Indeed, I don't find this image in the directory named public.
I've seen that Laravel automatically compiles the image if the latter is pointed by the CSS url property. Why isn't it the case with the html src attribute? How can I solve this problem?
Use mix.copyDirectory('resources/<your folder images>', 'public/<your destination folder images>) in your webpack.mix.js file.
(The css compiled images were in fact due to mix.less(<the css file>, public/<the css destination file>))
See 1) https://laravel.com/docs/8.x/mix#copying-files-and-directories and 2) https://laravel.com/docs/8.x/mix#working-with-stylesheets
i am an absolute beginner in laravel i have a basic structure for now, there is an app template which contains the structure of the view i.e
head
navbar
#yield("content")
footer
now the structure is working fine now for some specific pages i have to include google map the map blade is placed inside includes/map.blade.php this is my index blade
#extends("app")
#section("content")
the content goes here
#extends("includes.map")
#endsection
basically after the content i want to put the map so that it comes above footer but somehow whenever i try to extent it it always comes at the top
If you want to include the map then it should be #include (doc):
#extends("app")
#section("content")
the content goes here
#include("includes.map")
#endsection
You cannot use two extends.
Instead of #extends("includes.map") use #include("includes.map")
I am creating a joomla template. In order to get the contents of a page I have this: <jdoc:include type="component" />
How can I explode this or add the contents of the component to a variable?
You can't and you shouldn't. The right way to modify the content before rendering it (assuming that's what you want to do) is to use content plugins or system plugins.
Especially the "onAfterRender" plugin allows you to pick the current body, edit as you wish, and then push it back, e.g.
$body = JResponse::getBody();
$modifiedBody = doSomethingWith($body);
JResponse::setBody($modifiedBody);
Instead, if you just want to change the default layout of any component, you should look at template override
I just bought a WrapBootstrap theme and am trying to insert it into my CodeIgniter application. I've never used WrapBootstrap and am not sure what the next step is because many of the files have ruby in them (they are .erb files).
Here's what I have found:
First open your CSS files and replace all calls to ../img/ dir with plain images/ to make pipeline find the graphic elements of the theme .
For using the glyph you should create a new directory, fonts, to copy the glyph images there and expand the usable assets in application directory
Would I be able to use it if I just copied the JavaScript, images, fonts and style sheets? (if I took all of the assets)
Do this:
Put the css, js, img and other asset folders into a folder called assets at the same level of Codeigniter's index.php. The files in these folders will be referenced from the html files like this (example with css): <link rel="stylesheet" type="text/css" media="all" href="<?php echo base_url();?>assets/css/style.css" />
The html files go to the views folder. You'll see that each html file is repeating a header and footer structure, so you can isolate this structure into a header and footer view. Normally, the header starts at the doctype declaration and ends at the main section (inside the body), and the footer starts at the end of the main section and ends with </html>. The rest (the main section), will be the view for that html. So you'll end up having: a header view, a view for each html file and a footer view.
Header view: contains the <head> section and (normally) the nav bar. In the head section you reference the files (css, js, img) like I've written in the first point. Change the nav bar links to link to the correct controller (see last point).
View for each html: contains the content of the page. At the top you should load the header view and at the bottom the footer view. You can name the view like the html file but be careful with the home (index.html). You'd better name it "home".
Footer view: contains footer content and javascript files, which you should reference like the ones in the header.
To call each view create a controller with the name of the html and load the view in the index function of the controller. For the home view use the default_controller in routes.php.
The .erb files are probably for backend processing of contact forms, so they're of no use if you use Codeigniter. You should replace them with controllers and models.
Our group needs to have a standard Common Look and Feel (CLF) for all our web applications. the base line for them all is the same, and certain items like the css references can have customization.
We want to find a way to create either one full layout file or partials that can be shared by all.
I have read many postings and the layout variable on views do not have the ability to read absolute paths.
Can we get a razor method to read XML and render to our layouts, much like the renderbody() does?
EDIT:
We would like to have items like the css, standard layouts etc in one project. Then this could become a distributable package for development teams.
Example of the final output we are looking for:
_base.cshtml example.
#model CLFModel
#CLF.Header(...)
#CLF.LeftMenu(...)
#CLF.OptionalRightMenu(...)
#CLF.Body(...)
#CFL.Footer(...)
The CLF.Header would contain something like below, and would be render from either a file or a pre compiled reference.
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="#Model.dcLanguage" lang="#Model.dcLanguage">
<head>
<meta charset="utf-8" />
<title>#Model.PageTitle</title>
meta tags.....
CSS required links ....
CSS section for custom link references ...
script tags(required)
optional section for script tags
</head>
You can create as many partial view as you want and just include them into the view you are rendering using #Html.Partial("YourPartialView"). You can create a _MasteLayout, which contains various partial views and #RenderBody for maintaining a consistent feel