I have problem with including Joomla views. I have many views in my extension and I want to include another one in my Dialog.
How can I do it?
In my first view I have this code:
<div id="modalDostawca" title="Dostawcy">
<div id="wewM">
//in here i want to include view data/tmpl/default.php
</div>
</div>
What kind of extension is your extension? A module? A component?
If it's a component, what you are trying to include is a template for a view, not a view! (the view is the one with view.html.php). Create a view + template for what you are trying to see. I don't think Joomla! can call multiple views at the same time. If you can reuse code inside models (if this is your concern).
You can also include files the normal way, with include(...).
Related
Created a template folder inside views folder and in header.blade.php and added the following code
<ul id="sidebar">
#stack('sidebar')
</ul>
And created another category.blade.php inside views folder and added the following code
#include('template/header')
#push('sidebar')
<li>Sidebar first</li>
#endpush
A #stack can only be defined in an outer layout. So if you want to use #push, you have to use #extends('template.header') instead of #include('template.header').
In your case I don't think it is okay to use #extends you probably use an other layout file.
I searched for it in the Laravel issues and I found this Thread. Maybe this can clarify some things for you.
This can be particularly useful for specifying any JavaScript libraries required by your child views
better to use #include insted #push and #stack
Is it possible to force laravel to execute the parent view then the child view ? I use a master view with some view composers to create a menu and set some variables, then in my sitemap subview, because the master view is computed after I end up having my menu not created yet.
#extends('layout.master')
#section('content')
{{-- Render this after layout.master --}}
#endsection
Maybe I missed some possibility here.
If you watch code that blade generate in storage/framework/views/some_name.php you can see next code:
<?php echo $__env->yieldContent('content'); ?>
It`s working something like PHP inlcude, when code come to this line it come in to this file with content.
That`s why you can not load master view and then subview.
I have two templates that are almost identical. It's the mail template, but it should be in two different places. So they are extending the two different templates, but this and the section names are the only differences.
Here's the example:
#extends('layout.client')
//sections etc
#section('content')
//content here
#endsection
//other sections etc
And here's the second template:
#extends('layout.company')
//sections etc
#section('contentinner')
//content here
#endsection
//other sections etc
The other sections are mostly imported libraries to make the content work.
How should I approach this to not repeat the code?
Create another template and include in your section
<div class="col-md-3">
#include('layouts.your_template')
</div>
I solved a similar issue using components.
I found that it is good to have one master layout, but if you have parts of the code you need to include in many pages, it is better to use components. This provides an excellent example of the use of components.
Put your template into components.yourtemplate.blade.php
then in both layout.client and layout.company put
#component('components.yourtemplate')
#endcomponent
where you want your template code to be included. You can include the same component in many views.
I just started learning Laravel, and I want to include a second controller into my main layout.
The route is the default root directory: /
And the layout looks like this:
<div class="container">
#yield('content')
</div>
<div class="basket">
~basket comes here~
</div>
I want to show the user's basket, but I need DB queries for that, and I can't find a way to include an other controller, atleast not with routing.
I'm not really asking for code (Sadly i didn't find a better place for this question), probably I just need a designing tip, I really feel I'm trying to do it wrong, since I couldn't find any relevant/helpful information for this.
And I dont want to put the basket into every controller that uses my main layout.
Any kind of help would be apreciated, I'm really lost :)
You should use view composers. Open you AppServiceProvider and inside the boot() method add the following:
view()->composer('your.layout.name', function ($view) {
$basket = ...// Your basket query here
$view->with('basket', basket);
});
This basically says, when view with name your.layout.name is composed, add variable with name $basket.
I have a basic cms that loads content into pages that have mustache tags to indicate where in the html code those contents will appear.
The contents are specified in a widget model which indicate which type of content is to be displayed, so for example, freetext with id. or another model and id. each one of those models will be displayed differently based on the model they are based on.
I can imagine this becoming and bit unwieldy, is there a way to have a separate folder to put those widgets in so that it doesn't clutter my main code.
Something like apotomo does on rails would be good, but for codeigniter.
A widget model? That is not so nice. Have you tried looking at PyroCMS?
https://github.com/pyrocms/pyrocms/blob/master/system/pyrocms/modules/widgets/libraries/Widgets.php
From the sound of it you may be more interested in our Plugins library (sounds like the same thing with a different name). It is set up with a MY_Parser and runs on top of Dan Horrigan's Simpletags implementation.
Either way this has all be done plenty. If you want some more specific tailored advice you might have to demo some of your code.
Create a folder inside application/views called widgets. Put your widgets inside that folder and create a separate file for each widget (d0h).
Next, you have 2 options (at least that i know of):
a.) Load the widgets into variables inside the controller, then pass them to the main/general view
$data['widget_twitter_feed'] = $this->load->view('widgets/twitter', '', false);
$data['widget_something'] = $this->load->view('widgets/something', '', false);
$this->load->view('my_main_view', $data);
b.) Load the widgets inside the main/general view itself
<html>
...
<div id="sidebar">
<?php $this->load->view('widgets/twitter'); ?>
</div>
...
<div id="footer">
<?php $this->load->view('widgets/something'); ?>
</div>
...
</html>