template_********() info/samples
Intra-page navigation (TOC)
template_include()template_includes()s do like they sound: they include something ;) Specifically, template_include() will get the identified file from either /templates/your_template/ or /templates/ and use any specified parameters as 'default' for anything in the included file that uses those particular params. Think "sidebar, footer" and you're close pretty close to how template_include is generally used.
template_includes()s make it easier to build your web your way by off-loading big chunks of code to a more-focused file, which are (of course) fully customizable. You can let the generic versions of various files in /templates/ do their thing, or copy one to your /templates/your_template/ folder and customize it as you see fit.
There are no $params to chase through template_include() because Quam Plures can't know what params the included file might need. The thing is though that if you include a file that uses $params for whatever reason, you can pass those values through template_includes().
You can also include your own custom file. Simply add the properly formatted template_include() tag to the appropriate file (usually a main or an incl) and add the actual file to your /templates/your_template/ folder.
When template_includes()s play nice they include files that close any html tags they open. You should make your template_includes play nice by writing included files that play nice :)
We have a handful of 'stock' files to make building your own template a little easier.
To customize any of these simply copy them from the /templates/ folder to your /templates/your_template/ folder and create something awesome. QP always looks in /templates/your_template/ first then /templates/ if it didn't find the file you are including.
To a custom file simply create the file and use template_include( 'your_file' ) to include it. The name can be whatever you want; "dot inc dot php" is easy and it works, so there you go.
Very Generic Sample:
<?php
// --- --- --- --- --- --- --- --- --- --- ---
// --- SOME FILE INCLUDED HERE ---
?>
You can supply an array of params to the included file, and get really complicated about it if need be:
<?php
// --- --- --- --- --- --- --- --- --- --- ---
// --- SOME FILE INCLUDED HERE ---
?>
<?php
// --- --- --- --- --- --- --- --- --- --- ---
// --- SOME FILE INCLUDED HERE ---
'a_param' => 'your_value',
'another_param' => 'your_next_value',
) );
?>
<?php
// --- --- --- --- --- --- --- --- --- --- ---
// --- SOME FILE INCLUDED HERE ---
'a_param' => $params['a_param'],
'another_param' => $params['another_param'],
) );
?>
SPECIAL CASE: including a page based on the value of $disp:
<?php
// --- --- --- --- --- --- --- --- --- --- ---
// --- MAIN CONTENT INCLUDED HERE ---
// these cases already handled by this file
'disp_posts' => '',
'disp_single' => '',
'disp_page' => '',
) );
/* ------------- */
// --- --- --- --- --- --- --- --- --- --- ---
// --- MAIN CONTENT INCLUDED HERE ---
/* ------------- */
// --- --- --- --- --- --- --- --- --- --- ---
// --- MAIN CONTENT INCLUDED HERE ---
// these cases already handled by this file
'disp_yourfile' => '_yourfile.disp.php'
) );
?>
⇑ top of page ⇑
template_container()Containers are used as, well, "containers" for widgets. When you upload and install a template QP will find whatever containers it has and try to determine the best widgets for each under the circumstances (existing widgets, new blog defaults, others?).
Containers provide a very easy way to add and remove widgets from your web, but you might also consider using template_widget() after you know the widget arrangement that works best for you. Doing so will put a slightly smaller load on your server is why.
template_container() allows you to identify the container by name, and set some parameter values that will be used as default for widgets in that container.
If you do not plan on giving open sourcing your template (but please do!) you can name your containers in any way you like. Bob, Mary, Fred, Alice and Tom will work just as well as the names we use in the templates we provide.
You can name your containers anything but if you want to create a template for distribution via quamplures.net you'll want to stick to our naming convention if reasonably possible.
When template_container()s play nice they close any html tags they open. You should make your template_container()s play nice :)
ALL params with defaults shown >> 2 $params << and >> the $params motherlode <<
Extremely Loaded Sample:
<?php
// --- --- --- --- --- --- --- --- --- --- ---
// display "Something" container's widgets
'container_start' => '<div id="%sco_name%" class="container">',
'container_end' => '</div>',
'block_start' => '<div class="$wi_class$">',
'block_end' => '</div>',
'block_display_title' => true,
'block_title_start' => '<h3>',
'block_title_end' => '</h3>',
'coll_start' => '<h4>',
'coll_end' => '</h4>',
'collist_start' => '',
'collist_end' => '',
'group_start' => '<ul>',
'group_end' => '</ul>',
'list_start' => '<ul>',
'list_end' => '</ul>',
'item_start' => '<li>',
'item_end' => '</li>',
'item_text_start' => '',
'item_text' => '%s',
'item_text_end' => '',
'item_selected_start' => '<li class="selected">',
'item_selected_text' => '%s',
'item_selected_end' => '</li>',
'item_selected_text_start' => '',
'item_selected_text_end' => '',
'link_default_class' => 'default',
'link_selected_class' => 'selected',
'link_type' => 'canonic', // 'canonic' | 'context' (context will regenrate URL injecting/replacing a single filter)
'notes_start' => '<div class="notes">',
'notes_end' => '</div>',
'thumb_size' => 'crop-80x80',
'limit' => 100,
) );
?>
⇑ top of page ⇑
template_widget()Using template_widget() allows you to place a widget directly into your page flow without the use of a Container. Doing so is harder to start with because you have to edit the appropriate files with the right bit of code, but will save your server a measurable amount of work. Think of Containers as "middle-men" that you want to cut out of the loop and you'll begin to enjoy template_widget()'s purpose.
template_widget() uses ComponentWidget->display() which uses ComponentWidget->init_display() to define the minimum parameters for displaying this widget.
You can, of course, also pass params that are unique to that particular widget.
lorem ipsum - this page is not done. It only shows widgets that are in a 'skin' in the old evo package. Needs to show all widgets with all widget-specific params. Needs to also show the params flow!
See template_widget() for samples
⇑ top of page ⇑
| Prev |
Up |
Next |
| Templates Tutorials |
Templates Tutorials |
Blog->method() info/samples |
|
|