No template definition found for the current content magnolia 5.7.9 - magnolia

I created a new component in Magnolia 5.7.9 in that I created a placeholder.ftl and placeholder.yaml in /templates/components and I can see them correctly under module resource files.
placeholder.yaml:
title: Placeholder
renderType: freemarker
templateScript: /xxx-module-versioning/templates/components/placeholder.ftl
placeholder.ftl
<p>Hello World! I'm a Placeholder Component.</p>
Here is the component in JCR that I programmatically create:
When this specific component renders it gives a rendering error: info.magnolia.rendering.engine.RenderException: No template definition found for the current content
Caused by:
info.magnolia.config.registry.Registry$NoSuchDefinitionException:
/xxx-module-versioning/templates/components/placeholder.ftl
at info.magnolia.config.registry.AbstractRegistry.getProvider(AbstractRegistry.java:136)
~[magnolia-configuration-5.7.9.jar:?]
Is there something I am missing or doing wrong with this configuration?

Value of mgnl:template should not be script but the template definition, so something like xxx-module-versioning:components/placeholder. More details can be found in templating documentation.

Related

How do you include a custom component resource into an AEM Social Communities handlebars template?

In AEM 6.2, I want to do this in handlebars.
<sly data-sly-resource="${'title' # resourceType='myproject/components/content/common/title'}"/>
Specifically, I overlaid the qnaforum.hbs and need to include it in there. The official documentation(link) says the correct way to do this is:
{{include this.id path="title" resourceType="myproject/components/content/common/title"}}
When done this way there are three problems:
The component appears, but then disappears from the page.
I get the warning "Forcing resource type is not supported when sling including on the client side"
There is a failed(404) GET request to http://localhost:4502/content/myproject/qna-index-page/jcr:content/qna-parsys/qna/title.html in the browser console (like it's trying to find the renderer for the title resource at that path).
In the same qnaforum.hbs file, Adobe is using the same include for their subscriptions component and it seems to work fine.
{{include this.id path="subscriptions" resourceType="/libs/social/subscriptions/components/hbs/subscriptions"}}
Does this type of include only work for Social Communities components? If so, how can I include a custom resource in the handlebars template?
I helped some one else who was facing a similar issue. I am attaching the code snippet that caused the issue you are facing (disappearing QnA list), and the fix for that.
The overlaid QnAForum component looked like this
{{include this.id path="qnaforum-top" resourceType="custom/components/modules/qnaforum-top"}}
{{#if-wcm-mode mode="EDIT" }}
<div class="scf-includeClientLib">{{includeClientLib js="cq.social.commons.widgets, cq.social.toggle"}}</div>
{{/if-wcm-mode}}
<div data-module="qna-index" class="scf scf-forum scf-qna " data-component-id="{{id}}" data-scf-component="social/qna/components/hbs/qnaforum">
{{!-- Other QnA code --}}
</div>
But code should be like this
{{#if-wcm-mode mode="EDIT" }}
<div class="scf-includeClientLib">{{includeClientLib js="cq.social.commons.widgets, cq.social.toggle"}}</div>
{{/if-wcm-mode}}
<div data-module="qna-index" class="scf scf-forum scf-qna " data-component-id="{{id}}" data-scf-component="social/qna/components/hbs/qnaforum">
{{!-- moving line1 from previous code snippet inside this parent div}}
{{include this.id path="qnaforum-top" resourceType="custom/components/modules/qnaforum-top"}}
{{!-- rest of QnA Code }}
</div>
The change I made is, moving line1 in first code snippet into line 5.
The JS console does say missing HTML, but it gets included though. The reason for console error is the way include works.We try to fetch the html, and if we fail in fetching the HTML, we ask to sling to resolve the component.

Access to the current page from in a Tridion component template

I realize this might be slightly counter intuitive... but in a compound component template, is there a convenient way to access the Page object or the TCM URI of the page being rendered? I realize the result might be null if the component template is being rendered into broker or being debugged using the template builder. But I would like to get the page id if it is available.
Yes, you can create a TBB to do this. If you look on sdltridionworld.com there are Generic SDL Tridion 2011 Template Building Blocks available: https://sdltridionworld.com/community/2011_extensions/generic-2011-tbbs.aspx
In there there is a handly file called TemplateBase with a method called GetPage. You can use it to get the page in a TBB and then push the Page ID to the package.
This is also covered (for a C# TBB) in this Stack Exchange question: https://tridion.stackexchange.com/questions/743/accessing-page-object-in-c-tbb-used-in-the-component-template

Need help to create component template using Template building block

I need help with following scenario:
I have page template PT1 , which contains 2 TBBs and I have component template CT1, which contains 1 TBB.
I created a page using the Page Template(PT1) and added a component and selected the component template (CT1).
The TBBs pushing some text value to package and all three TBB are part of a single dotnet assembly and implemented in three different class, which is implementing "Itemplate" interface and implement "transform" method.
Problem:
In the published file i am able to see the content pushing by TBB used in Page Template PT1, but not able to see content which is pushing by TBB of Component Template CT1.
Typically, to output from a template you need to create a DWT TBB unless you are directly sending Output from C# TBB.
In your case, looks like you have all C# TBBs and are they outputting anything to the package. If not then I even doubt your PT will output any html.
You could use the Template Builder tool to debug your out of the template as in my comments the doc portal link will provide you guidance.

How to get objects in a razor template in Tridion?

I am writing a common Razor TBB, which will use in Component Template and Page template as per my requirement.
So that, I need a Page and Component object in the razor TBB according to applying TBB on Page Template and component Template
My requirement to display/use the metadata field values from Page/Component in specific area of the page.
That's why, i want to access metadata values by the object but unable to get the object,
Please also follow-up my comments with Frank.
Can any one suggest me?
Did you have a look at the (remarkably helpful) documentation that is available for the Razor mediator?
http://code.google.com/p/razor-mediator-4-tridion/
http://code.google.com/p/razor-mediator-4-tridion/downloads/detail?name=RazorMediatorDocumentation_v1.2.docx
These are full of examples that access the current Component and the Page. Just my 10 second search gives these fragments:
<body class=”#Page.Metadata.BodyClass”>
<div class=”#Component.Fields.NewsStyle”>
<img src=”#Fields.HeaderImage.ID” alt=”#Fields.HeaderImage.AltText” />
Edit: I see you added some more details in your follow-up comment. You might want to do as Bart suggests and add those details to the question. In the meantime, I'll spend a few more minutes searching the documentation for you.
The official documentation (the Word document I linked above), contains this example that seems to process metadata:
#foreach (var keyword in Publication.MetaData.SomeKeywordFields) {
<li>#keyword.Title (#keyword.Id)</li>
}
The output of the Razor template will become the Output item in the Package. So it doesn't make any sense to use a Razor mediator to process the Output item. For that you might as well use a regular C# (fragment or assembly) TBB.
Another edit: It seems that the Razor mediator's implicit Fields variable always maps to the Component fields and the Metadata variable always maps to the Component's meatadata fields. I've linked the above names to the relevant fragments on Google code for your convenience.
So you seem to have two options:
detect whether you are in Page or Component (e.g. by looking at whether the implicit Page variable is null or not) and then have conditional expressions everywhere (isInPage ? Page.Metadata : Metadata)
fix this limitation of the Razor mediator code yourself or hire someone to fix it for you

Symfony2 can't find template file

I am having issues using twig templates for email in SF2.
First, I created a template file located at:
MainBundle/Resources/views/Email/InviteNewUsers.twig
Next, I rendered the view as the body of my email: $this->get('mailer')->send($this->renderView('MainBundle:Email:InviteNewUsers.twig', array('code' => $invite->getCode())));
Unfortunately, this triggers an error: Unable to find template "MainBundle:Email:InviteNewUsers.twig"
is there something wrong with my file placement or my render command?
It was suggest that I might need a type in the template name, so I tested with InviteNewUsers.txt.twig and received the same error.
I believe the name of twig template needs to be InviteNewUsers.{_format}.twig. so it must be something like InviteNewUsers.html.twig, InviteNewUsers.xml.twig, or InviteNewUsers.text.twig etc
EDIT:
Also if your namespace includes first directory something like {Company}\BaseBundle\..., then your template path needs to be {Company}MainBundle:Email:InviteNewUsers.text.twig

Resources