Is it valid to expect that facelets template will use a default content in page which use the template but uses an empty ui:define?
template:
<ui:insert name="header">
default content here <!-- is it valid default content? -->
</ui:insert>
page which implements the template:
<ui:define name="header">
<!--nothing in page defined here but expecting that default content from template will be substituted in place-->
</ui:define>
The default content is not shown though in this case (the comment is not there in the real page)
No it will not show the default content in this case, it works as you defined it (pun intended)...
There is a <ui:define name="header">...</ui:define>, so there is something defined. That it does not contain anything does not mean it will display the default content. Remove the define and the default content is shown. As is according to the specs afaik.
Related
I want to append an image in input field in Demandware...
I am wondering to use style on Demandware's isinputfield tag, can i acheive this in Demandware Templates like on this tag
isinputfield formfield="${pdict.CurrentForms.helloform.nickname}" type="input"
Much Appreciated!
isinputfield is a custom ISML tag, implemented in template
{cartridge_name}/cartridge/templates/default/util/inputfield.isml
You can use the parameter rowClass to specify a CSS class for the surrounding div (you can actually see the code that uses this parameter in the template mentioned above)
e.g.
<isinputfield
formfield="${pdict.CurrentForms.giftcert.purchase.from}"
rowClass="label-above"
type="input" />
After that you would need to provide a CSS styling for the class you have applied.
One sublayout (.ascx) is using datasource from its template standard value.
Whenever I enable the cacheable setting with varyByData and varyByParm, I can't get all field values in __Standard Value of its template.
I checked cache.aspx page and it shows:
**web[standardValues]________0________0________0________10MB<br />
MaxSize is 10MB, but zero Count, zero Size and zero Delta information.**
Any ideas of how to solve this?
=============Update=============
I have fields in a template for CSS class names, such as h1, ul class, etc ... and all names initially set in its "__Standard Values".
Then, I have an item which calls the template's standard values as data-source.
This is another my post and it will help you more.
Sitecore Cache Issue
Could I know what the problem is?
=============Update 2=============
Current .cs file to get field values.
<asp:View ID="viewNormalMode" runat="server">
<nav class='<% Response.Write(myDataSourceItem.Fields["Nav Bar Class"]); %>'>
<h1 class='<% Response.Write(myDataSourceItem.Fields["Label h1 Class"]); %>'>
<i class='<% Response.Write(myDataSourceItem.Fields["Label i Class"]); %>'></i>
<% Response.Write(myDataSourceItem.Fields["Nav Bar Label"]); %>
</h1>
<ul class='<% Response.Write(myDataSourceItem.Fields["ul Class"]); %>'>
<asp:Literal ID="linkObjects" runat="server"></asp:Literal>
</ul>
</nav>
</asp:View>
Hope I understand correctly.
How Sitecore Cache work on sublayouts: Let take a main navigation (as sublayout) when you enable the cacheable setting global or from page to page you will get this result:
How your navigation looked at first page access after AppPool restart or application DLL update will look the same way on all other pages having cache on sublayout (even if you use another data source or something else, the code is cached/not executed).
But I think you have another bigger problem, move your fields for selection from Presentation Sublayouts on Data Template (Items) you will have huge problems on Locales. Beside you can add from code your classes as this:
You know your Layout, case you are in it, and you know you Context Item or your page definition Item, base on template name (Context.Item.TemplateName == "Article") put your CSS classes
Is there a rule on how to overwrite template definitions <ui:define> with <ui:insert>.
Template A:
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets">
template A content<br/>
<ui:insert name="content"/>
</ui:composition>
Template B:
<ui:composition template="/resources/templates/A.xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets">
<ui:define name="content">
template B content<br/>
<ui:insert name="content"/>
</ui:define>
</ui:composition>
Site 1:
<ui:composition template="/resources/templates/B.xhtml">
Site 1<br/>
<ui:define name="content">
site content<br/>
</ui:define>
</ui:composition>
Output:
Site 1
site content
Content for the <ui:define> is taken from Site 1, the content of the templates is not rendered.
Site 2:
<ui:composition template="/resources/templates/B.xhtml">
Site 2<br/>
</ui:composition>
Output:
Site 2
template B content
template A content
Content for the <ui:define> is taken from template B and template A, where strangely template B content is rendered before content of template A.
Is it possible to overwrite <ui:define> with a new <ui:insert> using same name?
Creating new names for the nested <ui:insert> is one possibility but its hard to keep track of the hierarchy and where insert's are used at all.
Unfortunately Facelets doesn't allow you to 'chain' insert/define.
In your first example (Site 1), there is single insert in Template A called "content". There are two definitions being considered; that of the direct template client (Template B) and that of the template client of Template B (Site 1). For this case, Facelets does not see that Template B has another insert. It just considers two competing definitions for "content", and the rule is that the top-most one wins, which is Site 1.
You did forgot to put the namespace on the template client though. The output you should be seeing is:
template A content
site content
Namely "template A content" is in the lowest template, outside the insert tag. It will be rendered directly. "site content" is in the top-most definition of "content".
In the second example (Site 2), there is no definition at all in the top-most template client. There is only one definition, and that's in Template B, so that one will be used. The output you should be seeing is:
template A content
template B content
You'll see "template A content" for the same reasons as in the first example, and "template B content" since it's the only definition. The nested second insert after that will be ignored.
Creating new names for the nested is one possibility but its hard to keep track of the hierarchy and where insert's are used at all.
It is indeed. Precisely for this reason I created a spec issue over a year ago for this at: https://github.com/eclipse-ee4j/faces-api/issues/1008
If this particular functionality is important to you please vote and/or leave a comment.
I have a pretty straight forward question, in regards to joomla templates.
The end result being : http://css3playground.com/flip-card.php
What I want to do is simple, in a sense, but need to know where to look;
I want to have the entire page wrapped in two divs, all the PHP code, to which class i can define in css and drop in some javascrpt so I can apply page transitions to that div. All of which I know how to do except for where to do it in, the PHP structure of joomla is new to me.
and also, after the first step is accomplished, create a second div after the content that would be dynamically loaded with content from clicked links on the page from within the template, but thats two questions at once lol.
Any ideas on the first part?
If you just want to use a div to encompass the entire template, do exactly that: wrap the template in a div and give it a custom class or id:
<html>
<head>
//stuff here
</head>
<body>
//insert the wrapper here
<div id="wrapper">
//template structure here
</div>
</body>
</html>
The file you want to edit will likely be named index.php located at public_html/templates/your_template/index.php.
For some templates, such as those by Yootheme, you will instead want to edit the file at public_html/templates/your_template/layouts/template.php (or /public_html/templates/your_template/styles/current_profile/layouts/template.php if you're using a profile other than the default).
Given the path to a Django template, is there any easy way to find a list of the template's inheritance chain? For example, if mytemplate.html inherited from user-section-base.html, which inherited from global-base.html, it would be something like:
>>> print(get_template_chain('myapp/mytemplate.html'))
>>> ['/project/myapp/templates/myapp/mytemplate.html', '/project/myapp/templates/myapp/user-section-base.html', '/project/myapp/templates/myapp/global-base.html']
I'm trying to write a static site generator that automatically regenerates static pages from Django templates, and I need to detect when the underlying template changes since last generation. For a single flat template with no inheritance, this is trivial, but for a template that inherits from a parent, which also inherits from a parent, I need to track changes of those files as well.
However, I can't find any simple way to retrieve this, short of manually parsing the {% extends ... %} tags directly. What's the best way to do this?
the cleanest way is to hook to the template rendering engine, and try doing it there. That however, will require a deep dive into its code. Unless you are already familiar with the code base, I would say that going for parsing is the easiest and fastest option.
This is a very hacky way ;-) ...but if you are open to changing Django code, you can go to django/template/loader_tags.py and change the ExtendsNode.render return statement from
return compiled_parent._render(context)
to
return compiled_parent._render(context) + f'\n<!-- {compiled_parent.origin} -->'
and the rendered template will end with the full path of all your template-extends, e.g. for the file I'm working on right now:
</body>
</html>
<!-- c:\srv\lib\admindash\admindash\templates\admindash\html5.html -->
<!-- c:\srv\lib\admindash\admindash\templates\admindash\bootstrap3.html -->
<!-- c:\srv\lib\admindash\admindash\templates\admindash\site-admin.html -->
<!-- c:\srv\www\school\templates\site-admin.html -->
<!-- c:\srv\www\school\templates\page-admin.html -->
<!-- c:\srv\lib\dashboard\dashboard\templates\dashboard\tctr\home.html -->
<!-- c:\srv\lib\studentdb\studentdb\templates\studentdb\tctr\tctr-base.html -->
<!-- c:\srv\lib\studentdb\studentdb\templates\studentdb\tctr\candidates\candidate-base.html -->
Hooking into the template engine would be nice, but I'm not sure it can work out-of-the-box since .render(..) returns a string and thus loses all meta-data. Perhaps if you create your own {% extends ... %} tag..?