it seems quite simple. i have a controller, a class/object and a view for it (show/edit). and i want to render this view in an overview/listing.therefore i have to extract the the 'content' section.
demo.blade.php
#extends('mainlayout.main')
#section('content')
Content of the object
#endsection
so i use in the overview template (overview.blade.php) the following code
$sections = View::make('demo')->renderSections();
echo($sections['content']);
what happens? the content here overwrites everything in the section (content) of the overview.blade.php
i also tried to take another name for the section like 'contentnew' and than ! it works.
so my questions?
should it work with section 'content'? or do i understand something wrong with the template engine?
why is 'content' handled different than contentnew. simple because it is not parse?
thanks for any help.
t00cg
Related
I make my own template , and its work well on www.90km2.com/index.php
But when I want to see com_content&view=category page on this link : http://www.90km2.com/index.php?option=com_content&view=category&id=23&Itemid=102
It doesn't work. Do you know why joomla didn't show my view?
I try another templates to see this page , all of them was worked well , but this view is not work with my own teplate :(
I would try copying the template which works then modify bit by bit to get your custom template then see when problem shows up. Or create a template which has the minimum stuff in there and see if it works. Just have jdoc:include type="component"/> in the body
For some reason, Laravel 4 won't update the content view that should be displayed in the browser.
For example, if I add one more item to the navigation menu, it is written on the view file, but not shown on the navigation list.
I have checked for any mispells, errors or anything related to this issue however I can't figure out if it's my mistake or it has to do with the cache.
What I've done:
Created the route for the url.
The related controller that will render the view.
Created the actual view with the content.
Added the item to the navigation file.
And I am sure that the view:
Extends with my layout
Included my content inside the #section and #stop'ed it.
And there are no errors displayed in the browser.
Also I've checked the storage folder which contains the view's cache, and I verified that the navigation file and the view file are phased correctly.
Looks like I need your advice guys.
Code as requested:
The route
Route::get('/account/profile', array(
'as' => 'account-profile',
'uses' => 'SettingsController#getProfileSettings'
));
Navigation
<li>Edit profile</li>
Controller
public function getProfileSettings() {
return View::make('account.profile');
}
View
#extends('layout.main')
#section('content')
Edit your profile...
Not yet...
#stop
First things I would do is:
Clear the view's cache folder.
check how you display the navigation, with #yield or #section, which should end with #show in the layout file.
If that didn't work maybe you could provide us with some code from the layout.
When I use my CListView Widget in a page the fontsize of my whole website changes. I use flowtype to scale my fonts and keep everything responsive. Only when I use this widget everything changes, nog only the data of the widget itself.
I tried to turn the css styling of the widget of and tried to control it via an own css file, but this doesn't matter.
<?php $this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider,
'itemView'=>'_view',
'cssFile'=>false,
)); ?>
The content of the view I'm calling doesn't matter either. Only when I remove the widget and put some text instead it changes back to normal.
Does someone have any idea what's happening here?
Quoted from official documentation for ClistView
cssFile property
public string $cssFile;
the URL of the CSS file used by this list view. Defaults to null,
meaning using the integrated CSS file. If this is set false, you are
responsible to explicitly include the necessary CSS file in your page.
Follow it, when you used CListView, default css .../listview/style.css file would be imported into your page, it could change your current layout if some of css is coincided with each other.
You can override it
$this->widget('zii.widgets.CListView', array(
'cssFile' => 'your-css-file-path.css',
...
)
So, eventually tried to copy the parsed code from the page source into my view. So in pagecode this was exactly the same output as the widget does in the page. Now I didn't had the resizing problem. So the widgets do something more then I can see.
For the solution I wrote an own widget to get my data in which I can control everything that happens. So no problem left anymore. Thanks for your help Telvin!
For my Codeigniter site, I started by making a view for each controller situation. This was impractical, as it would require going back to the code for each to make a change. So I changed approach and operated on a 'default' controller with optional fields. I then thought I could load special views as needed into it.
I put together this view with optional fields with fields for $title, $search_bar on/off etc. However, now came the content area. I was able to load more views into this default view using:
$data['content_views'][]='blocks/login';
$this->load->view('default/a', $data);
and in the 'default'view:
if(isset($content_views)&& (is_array($content_views)))
{
foreach($content_views as $content_view)
{
$this->load->view(&$content_view);
}
}
(and that works fine)
Two questions:
Am I making things to complex? Is this an accepted way of doing this? Or have I misunderstood the functioning of a view and how they are intended to work?
I want a way to mix the $content_view, i.e. a block of text, then a view. I'm not quite sure as to how to proceed. Say I want a message first, then a view, then more text. This method will only accept views.
Can anybody help me create this flexible approach?
Yeah I would say you're making things a little complex. While I may not be following your description well enough to know precisely how to respond, I can tell you how I do it:
First the whole site is run through a template so the header and footer are the container file and all views needed within the site are rendered as page type views - like an article page, a gallery page, etc. Components are loaded and passed to the views as strings:
$content['sidebar'] = $this->load->view('components/sidebar', $data, true);
That last true says to render as string.
Essentially, this means the page views are pretty much html with php echoing out the necessary elements. No views calling other views, which is how I read your example.
CI loads views progressively, so your controller can output like so:
$this->load->view('header', $header_data);
$view_data['sidebar'] = $this->load->view('components/sidebar', $sidebar_data, true);
$this->load->view('content', $view_data);
$this->load->view('footer', $footer_data);
and in content view, handle the sidebar like so:
<?php if(isset($sidebar)): ?>
<nav>
<?php echo $sidebar; ?>
</nav>
<?php endif; ?>
And, assuming you populate those arrays for each view it will render header, then content, then footer. And also render sidebar if it is present.
So combining everything, I'm basically saying you can load in sections in your controllers progressively, passing sub-views as strings to whichever section makes sense. That keeps your view controlling in the controller where it belongs and not in the view files themselves. In my experience, I have not had to write a site that was so complex that this construct wasn't perfectly suitable if the site is planned well.
I'm trying to access a Drupal View through my template and want to iterate through it's results to show data. Something simple, like:
foreach($fields as $field) {
echo $field['name_of_the_field'];
}
So i can have full control of my view display inside my teplate. And, of course, being easier to build my template in Drupal. Any help? Thanks in advance.
You can export a views template and then access what you need through that.
Go to the views, and under the 'Basic Settings' section. Click on the 'Theme: information' link.
Then, you'll see a list possible template links.
Click on one of those links and you'll see textarea with the template. Copy the template to a file with the same name as the link name and put it in your themes folder.
Anyway, once you have the proper template, you'll see what object you can iterate over.