Using template inheritance with Assemble - handlebars.js

Is is possible to define regions in the template, that would pull content from the page?
Let's say I have in my template the following structure:
<div class=sidebar></div>
<div class=content></div>
And from the page content, I would like to pull some html content to the sidebar, and other content to content div.
Is this possible?

With Swig as the Engine
Yes, this is possible. Seehttps://github.com/assemble/boilerplate-swig, in particular, this example, which shows how to use {% macro %} tags to accomplish what you're asking about.
If you want to use Swig, be sure to look at the readme as the assemble-swig repo as well. You have to register swig as the current engine in assemble:
assemble: {
options: {
engine: 'swig'
}
}
With Handlebars as the Engine
If the sidebar content will always be the same, on every page then you can use partials for this. Even if the URLs or active classes change on each page, this should work.
However, dynamic content using template or "block" inheritance, e.g. extend can be achieved with Handlebars helpers.
But since layouts are used with assemble this is a bit trickier to do with "out-of-the-box" helpers. To clarify, just about any helper I can think of will work great with assemble out-of-the-box, except for this - specifically because of how layouts work.
My suggestion is that you add to the existing feature request(s) for this on assemble and/or the handlebars-helpers project to add your use case and thoughts on what you want to achieve:
https://github.com/assemble/assemble/issues/38
https://github.com/assemble/handlebars-helpers/issues/16

#jonschlinkert You should update assemble's documentation, cause start with Assemble isn't so easy and a lot of things are little hidden.
So Luis, you can try this method, which currently works great for me too!
Assemble: Multiple points of content insertion in layout?

Related

List all Twig templates used in the current request

I'm using Symfony2 with Twig templating engine.
Is there any way to output a list of all Twig templates files loaded in the current request, including the ones loaded through extends, include, etc.?
That would make my life much easier when overriding third-party bundles' blocks, but I can't find a way to do it.
I've been looking for such a tool for a long time but never found it... The debug options of twig are very limited, and there is no tool in the sf2 dev bar dedicated to it...
I always add twig or html comments on top of each of my templates to get an idea of where I am and why during development or on the final page.
You can try this code, it puts filenames in HTML like this:
<!-- START templatename.html.twig -->
...
<!-- END templatename.html.twig -->
I know, that it is not a good solution, but it is better than nothing.
not a problem when you are working in dev in app_dev.php
expand bottom SF toolbar, click on 200 status or on #your_rote_name
you will redirect to smt like localhost/_profiler/s0meha5h?panel=*
then click on left menu on TWIG then url will be like localhost/_profiler/s0meha5h?panel=twig
and you will see all templates like FolderYourBundle:Folder:twig_file_name.html.twig that loads one by one!

Creating custom layouts for Images in page content TYPO3 6

Typo3 provides option to add multiple images to a page content, but all the images are wrapped under some default <div> tags. I want these images to be wrapped under <ul> and <li> tags instead and giving my own custom CSS ids and classes to it.
There are not many resources on TYPO3 for me to approach this issue. Can TYPO3 allow to use custom tags for the page content elements?
UPDATE
From Jost's answer was able to get my images displayed, but how do I split the image details?
My each image will have title, alt-text, image-path and image-link. Now, using TypoScript how do I retrieve this, because each details has to go in separate tags.
Check the TypoScript object browser. There you will find the object tt_content, which contains the rendering definitions for content elements. The rendering definition for images is found at tt_content.image.20, for example
tt_content.image.20.imageStdWrap.dataWrap = <div class="csc-textpic-imagewrap" style="width:{register:totalwidth}px;"> | </div>
The default definitions given there are usually provided by the static TypoScript of CSS-styled-content. You can overwrite them in your own TS, but when updating to a newer TYPO3-version, the default template may change, which could result in additional wrappers.
Update
Most content rendering in TYPO3 is defined in the TypoScript object tt_content. You can browse all TS-objects that will be used on a page by selecting the "Template" module and the page in question, and then choose "TypoScript Object Browser" in the selectbox at the top of the window. To understand what that stuff means, knowledge of TypoScript is necessary (Tutorial, Reference).
You can add your own TypoScript, which may override existing settings. You can do that in the Template-module too, but usually this is done by creating a file containing the script somewhere in the fileadmin folder and including it from the Template module.
The above enables you to edit the markup of the page. (Additional) CSS is usually defined in external files, that are included by a PAGE object (see the reference about that).
This post is a bit older but I want to add the following:
If you want to understand how the different content elements are wrapped, you may have a look into the css_styled_content extension. I assume that you have included the "Static Template (from extension)" in your main Typoscript template.
You can find the setup.txt here:
typo3/sysext/css_styled_content/static/setup.txt
There you´ll find the line Jost mentioned in line 860 (TYPO3 version 6.1), for example. And of course a lot of other definitions, too.
But check to read the documentation and tutorials on typo3.org.
HTH
merzilla

Richfaces+SEAM: good doc describing s:decorate tag functionality?

EDIT: Would it be more elegant to tweak the GUI using CSS, or some other way?
Is there any good documentation (the official one only shows a basic example) for this tag?
I want to use it like this:
<s:decorate template="template.xhtml">
....richfaces UI...
</s:decorate>
in order to format a list of question-answer pairs without using rich tables or nested panels.
I get the gist of what it does, but I don't understand exactly how I can edit my own template.xhtml files and make the UI look as I want by using it.
The s:decorate is basically the same as ui:decorate with some extra functionality like rendered
The ui:decorate can be explained as:
The UI Decorate tag is a templating
tag that decorates content included
from another Facelet. Any content
outside of the UI Decorate tag will be
displayed by the Facelets view
handler. Any content within the
decorate tag will be passed to the
associated template as parameters or
simply ignored. You can use nested
ui:define tags to pass named content
to the associated template. See
ui:insert for more information.
For more info you can read here and here
To answer your update question. You should also use CSS to style the content of your template

Hide right-sidebar on specific node/module

I am setting up my first drupal (6) site and so far I like the system.
I've now run into a problem however: to give the content more space I want to hide the right-sidebar (with the navigation menu etc.) on every page from a specific module (or also fine: for a specific node/view from the module)
The only way I've come up with is to add some CSS to the module CSS files, but this doesn't seem very clean to me since I would need to redo it on every update (also the module uses 5 CSS files for different views)
Is there a better way to do it?
To be clear: I don't want to just hide a block, I want to hide the whole sidebar
Hmmm. Is this a custom module or something commonly available? Some modules allow you to create custom tpl.php files (see the theming guide) for them. This might quickly solve your problem.
If you are theming a node, then it is significantly easier. You can theme a specific type of node by naming convention (again via .tpl.php files in your theme). You can check out how to do that here.
Definitely check out the theming guide, since you will probably want to create your own theme instead of hacking on one of the core themes (not recommended). Typically you can copy /themes/garland into /sites/all/themes/my_garland, switch your site's theme to that and then make whatever changes you need (otherwise you'll have to reapply changes every time you update core).
Finally, you can check for path arguments (which seemed weird to me at first) if you want to do things in PHP that are more complex (see the arg function). If this is your first Drupal site, you may also need to know how to include css programatically.
Good luck! Drupal is a fun and interesting product.
You can configure the block visibility for each individual block and path in your website (admin/build/block). Under 'Configure'/'Page specific visibility settings'/'Show block on specific pages' you can set the navigation menu block not to be displayed for some specific routes. If a sidebar has no blocks to display it will hide itself allowing more space for the content.
You could use the Context module, with it you can, among other things, set rules for each block/menu where and when i should be shown (or not). You could also do this the way Josep explained but with Context you get more options.
And as Josep said when there are no blocks active in the sidebar it should disappear automatically, if not check your page.tpl.php it should have something like this in it:
<?php if ($right): ?>
<div id="sidebar-right">
<div id="sidebar-right-inner"> <?php print $right; ?> </div>
</div>
<?php endif; ?>
So if there is nothing in the Right region it doesn't display the sidebar. Maybe you have to change the name of the region, depending how they are called in you template.
I believe you already got the answer or a way to fix your problem.
There is a simple way to fix your problem. Here's a link.

Building a "themeable" website

Websites like Wordpress and Tumblr allow designers to create themes that users can select. In general how would you architect a website to be flexible enough to allow custom themes for users?
Take a look on how Django does it. Django uses a Model-View-Controller-like approach in which you use views to populate a context, and then use that context to process a template. Note that Django has its own MVC terminology.
For example, if we say that our context reads as follows (in pseudo code),
author = 'mntnoe'
title = 'My Title'
content = '<p>This is my content</p>'
we could use the following template:
<h1>{{ title }}</h1>
<div class="author">Author: {{ author }}</div>
<div class="content">
{{ content }}
</div>
Now, you are free to replace the template (or collection of templates) with another one without affecting how the site works.
Seperate content from formatting by using proper html and css. That means using css files for the style rather than inline style inside the html.
You can make several css files (themes if you wish), and switch between them using javascript.
Let your serverside technology of choice simply generate easy to adjust, by css and images, html. A great site of examples is http://www.csszengarden.com/. It emits the same html every time but uses different css and images to style it. Take a look at the html they generate to get ideas.

Resources