I've got the section in my master template
#section('errors')
// ...
#stop
I wanna yield it in some specific place of my other page, I extended that page from master template and yielding the section
#extends('template')
#yield('errors')
But nothing is yielded. I assume that I am just doing this wrong. Is there the right way?
Normally you put in master template:
#yield('errors')
and in child template you use:
#section('errors')
// ...
#stop
to display something in place when in master template you used #yield('errors')
But in your case if this section appears on many pages you can use in parent template:
#yield('errors')
and in child template:
#section('errors')
#include ('errors')
#stop
and create new errors.blade.php file that displays error.
Of course everything depends on your needs. You can of course also in parent template use:
#include ('errors')
instead of yielding.
Related
I have a .php file which uses some WP functions e.g. get_stylesheet_directory_uri(), query_posts, etc... and $wpdb of course.
File it self return JSON data so it is not intended for viewing on its own.
I'm not looking for template, or clicking around in WP dashboard, I just want to know where is the good place in WP file structure to put the .php file and expect WP functions and object to be available.
And also what do I need to include at the top?
You can create custom template in theme root directory or in child theme (child theme is important when you are creating custom template).
template should contain template name, header and footer function.
eg. custom-tpl.php
<?php
Template Name: My Custom Temlate
get_header();
//your other functions and content goes here
get_footer();
after creating template it will appear in your edit page template section under drop down. select custom template for your page and view page you will get your output
You can create a custom page template.
Inside the page template:
<?php
global $wpdb;
[here you will write your code]
?>
On the front pages where you want the json output, use this url
http://domainname.com/wp-content/themes/themename/custompagetemplatename.php
Use your domain name (domainname), theme name (themename) and theme template file name (custompagetemplatename) in place of example names in the url. This url will return you the output for your code.
About this comment in your template:
<?php
/* Template Name: Full Width Page */
?>
You do not need a template name in the header of your file unless you want to use this as a template for pages in wordpress.
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.
For some reason, after doing a ?flush=all, a certain page type is not able to locate it's default template. I figure out that it's not loading it's template file after appending showtemplate=1 to the URL. The dumped raw template shows nothing for the default template.
Pastebin: http://pastebin.com/uMLefAsP
I wish someone could point me to the right direction here, for I have no idea where to start debugging.
Thanks, Jan.
Firstly, and I have to ask: Is there actually a PageType called "CommunityExtensionPage"? PageTypes need to be named the same as the required template, for the template to be picked-up automatically.
You seem to have two template files "CommunityExtensionPage.ss". One at "templates/CommunityExtensionPage.ss" and one at "templates/Layout/CommunityExtensionPage.ss"
It would be useful to see the contents of both files. SilverStripe will look for "CommunityExtensionPage.ss" in the top-level of the "templates" dir before looking in "templates/Layout".
If "templates/CommunityExtensionPage.ss" is found, it will also try and look for "templates/Layout/CommunityExtensionPage.ss" and render this into the $Layout template variable. Otherwise, it'll use the default "templates/Page.ss" and request "templates/Layout/CommunityExtensionPage.ss"
Does your "templates/CommunityExtensionPage.ss" template contain a reference to $Layout? If not, then the contents of "templates/Layout/CommunityExtensionPage.ss" will not be rendered.
I have a create form which is loaded using renderPartial (standard after using the yii crud tool):
<?php echo $this->renderPartial('_form', array('model'=>$model)); ?>
I removed the code which renders the sidebar menu, and the menu doesn't show anymore. But still there's some generated code left when I look into browser my source code:
<div class="span-5 last">
<div id="sidebar">
</div><!-- sidebar -->
</div>
This messes up my layout and I can't find where I can remove this last part. Does someone know where this happens?
There are two things to consider here, do you want this removed over the whole site (i'll explain all methods). If so go to the following directory
/protected/views/layouts
Then edit the column2 layout, which is likely the default layout being used and remove the sidebar code. Now all pages should no longer have the sidebar.
If you want to remove this either on all actions of a controller or for a specific controller action, do the following. Duplicate colum2.php and call it say nosidebar.php. Then in the nosidebar.php file, remove the sidebar code.
To change all actions in a controller specifiy the layout like so.
class AccountsController extends Controller
{
public $layout='//layouts/nosidebar';
or to change a specific action add this inside the action method
$this->layout='nosidebar';
i have a little problem that i dont know what to do with.
i have a template with
header
content
sidebar
footer
on all my page the only thing that need to change is the content, so how can i pass data to my sidebar/footer
do i need to make a controller? or do i need to make a library and load it in my template.php file?
i use this template system
http://williamsconcepts.com/ci/codeigniter/libraries/template/index.html
I am not sure about your specific Template Library, but I do know that generally this is done by nesting views inside other views, and as long as the data is loaded into the initial view, it propagates to nested views as well.
Example without Template library
Controller function
function index() {
$data['some_var'] = "some value";
$data['another_var'] = "another value";
$this->load->view('first_view',$data);
}
first_view
<? $this->load->view('header') ?>
<h1>Content</h1>
<? $this->load->view('sidebar') ?>
<? $this->load->view('footer') ?>
In this instance, the $data that is loaded into first_view propagates to header,sidebar,and footer.
So you can use $some_var or $another_var in any of these views.
UPDATE
Another way you can load data in to your views globally is with this function
$this->load-vars($data);
Where $data is your view data, this statement just before you load your template should allow all of this data to be accessed in any view loaded by the template. While this is a shotgun approach, it is the suggested way to do this by your chosen template library.
If you will only ever change content, then there is no need to set up regions for your header, sidebar or footer - just add their contents to your main template file.
However if you will infrequently need to change the content of these regions, I would create "default" views for these regions, and load in each controller constructor, like thus:
$this->template->write_view('header', 'default/header');
$this->template->write_view('sidebar', 'default/sidebar');
$this->template->write_view('footer', 'default/footer');
You can then either extend these default region views or overwrite them on a per method basis (refer to the documentation of your library to find out how).