main page -> welcome.blade.php
#extends('layouts.footer_back_to_top')
#section('footer_back_to_top')
#endsection()
footer page -> footer_back_to_top.blade.php
<p id="back-top">
<span></span> Back to Top
</p>
#yield('footer_back_to_top')
The question I want to ask is without using #yield('footer_back_to_top') still will display the result?
No, result won't be displayed. You should use #yield to make this section displayed and in child view you normally define #section where you define what should be displayed.
Related
I have a sidebar include file that is present on every page of the website I am working on.
layout.blade:
<div class="after-login buying-process-wrapper">
<!--page content-->
{{ $content }}
<!-- end of page content-->
<!-- Sidebar -->
#include('layout.sidebar')
<!-- End of Sidebar -->
</div>
My controller sets $layout and renders the above blade file, but layout.sidebar is an include file which requires PHP to populate it's content.
Can I set a controller/route for this sidebar alone (and how would I do it?), or am I forced to have to duplicate the same calls to the function that handles the sidebar content in every controller?
I'm trying to find a better solution than having to go in to every controller and calling ->sidebar() every time each page is loaded.
Thanks
Why are you still using Laravel 4.2? It't 5.7 now and I strongly recommend you to upgrade to the latest version.
Answer to your question:
No, you don't need to call functions that handle your sidebar contents in every controller. You can share you common data across all or some of your views by using View Composer.
From Laravel 4.2 Documentation:
View composers are callbacks or class methods that are called when a view is rendered. If you have data that you want bound to a given view each time that view is rendered throughout your application, a view composer can organize that code into a single location. Therefore, view composers may function like "view models" or "presenters".
If you are using newer versions of Laravel, remember to switch to the right documentation from the right upper corner.
Also, when using Blade #include directive, you can optionally pass variables into the "included" components:
#include('layout.sidebar', ['my_var' => 'value goes here'])
And you can use {{ $my_var }} in your component just like you normally would in your blade templates.
I'm creating an app in Laravel 5, with a footer that's going to have alot of links with sections. The idea is that, when I click on a footer link of a section, it's going to redirect me to a template page, where on the left, are all the links in that footer, and on the right, the content of the link I clicked.
For example, on this picture, I click on Link A in the footer, and it shows all the links from Section 1(with Link A underlined) on the left, and on the right it shows the content of Link A.
Basically I want to know if there is a good way to do this without creating 50 different templates(one for each link of the footer).
You can do it by using just 3 templates:
main.blade.php:
<html>
<body>
#include('sidebar')
..
#yield('content')
..
#include('footer')
</body>
</html>
sidebar.blade.php
<div class="sidebar">
#foreach($sidebar_links as $link)
// print $link
#endforeach
</div>
footer.blade.php
<div class="footer">
Section A
Section B
</div>
Controller action:
public function getMenu($section) {
$sidebar_links = // Get sidebar links of the section which is clicked from the bottom links
return ('main', compact('sidebar_links'))
}
Note: I have not tested this, but it should give you the basic view.
You can use Request::segment() for finding the active link. For example the link of Link A = /link/a then we can say Request::segment(2) == a. You can you use that to show what is the active link.
Link A
Link B
Link C
On a page and all of its subpages, I want to include a certain section. In my default template I added this:
<div class="container">
<f:render section="Productsearch"/>
</div>
But I want this section to only be included on certain pages. How can I achieve this?
Use a different layout on these pages. You can probably do this by using a setting (plugins.tx_yourext.settings.layoutName = Layout2.html), and then using that in the template:
<f:layout name="{settings.layoutName}"/>
The layout on the special pages renders the section, the usual layout does not render it.
EDIT: You could also just use a condition in the layout. Set plugins.tx_yourext.settings.showProductSearch = 1 (or 0) on the pages, preferrably using a TypoScript constant. Then use it in a condition:
<f:if condition="{settings.showProductSearch}">
<f:render section="Productsearch"/>
</f:if>
I'm working on a scrollable one-page website, in which each div represents a different section. For example, url is dynaone.com/index.php, and when I click on the menu's different buttons, it changes to /index.php#s1, #s2, #s3, and so on. In section nº 2 I added another menu that works with php GET, in a way that when you click on one of the buttons, it redirects you to index.php?id=1 and so on. Of course when I first tried it, it scrolled me back to the top of the page, 'home', as I wasn't specifying the section. But when I did, assigning "index.php?id=1#s2" to the first element in the inner menu, it redirected me to section 1. It doesn't matter which number I write after "#s", it will keep putting section nº 1 on top of the page.
I'm using SMINT's demo as a base, adjusting it to my website's needs, but I couldn't find anything related to GET method issues on the plugin's page.
I would really appreciate some help with this, as it's very annoying having to go back everytime I click to correctly view section nº 2.
This is part of my inner menu:
<div id="botonera_productos"><ul>
<li> Quemadores </li>
<li> BCAAs</li> </ul> </div>
This is my php section:
if(#$_GET['id']==1) {
?>
<figure><img src="imagenes/quemadores/1.jpg"><figcaption> ULTIMATE L-CARNITINA 500 60 TABS - <b>$330</b> </figcaption></figure>
<?php } ?>
And this is the site's main menu:
<nav class="subMenu" >
<div class="inner">
Home
Nosotros
Productos
Local
Envíos
Consultas
Facebook
</div>
</nav>
Thank you.
The question isn't very clear but basically:
The anchor is an HTML construct. So once the page is already loaded, you can use #whatever to take you to wherever on that page that the anchor has been defined; ala <a id="whatever">
The PHP arguments, like ?id=1 - a new page will be loaded depending on what you use here.
You can use anchors in conjunction with a PHP page (ie. a PHP page may have multiple anchors) but you cannot load a new page with anchors alone.
Maybe Javascript will help you achieve what you want to do. With AJAX calls and the like then there are far less restrictions on how you load data.
I am using drupal 7
views-view--myview.tpl.php sample code
<?php if ($rows): ?>
<?php print $rows; ?>
When i see this in firebug i see the structure
<div class="item-list">
<ul>
<li class="views-row views-row-1 views-row-odd views-row-first"> </li>
<li class="views-row views-row-2 views-row-even "> </li>
Now how do i inject a div in each of these li.. Is this possible without using jquery?
If you go the the "Edit" page for the view, you should see a link called "Theme: Information". It's under the "Style Settings" section. If you click this, you can see a list of all the possible template that your theme will look for when displaying the view. In bold will be the file it is currently using.
views-view--myview.tpl.php is to high up the chain to do what you want. If you want to inject a div (the same div) around each field you output, then I think the file views-view-field.tpl.php is what you are looking for.
The file contains just the line
<?php print $output; ?>
So there you can insert the desired div (after you copy it from views/themes into the template directory for your theme, of course).
If you investigate the Theme Information link some more it describes how to be even more specific in naming the view template files, for example if you wanted to theme a specific row differently you could use the file views-view-field--entity-id-X.
Hope that helps!
EDIT for comment
To go a different route, you can also edit the field settings for your view. Under the Field tab on the edit view page, you can click the links for each field. There is a Suffix setting available you could use to inject a div after the field is displayed.