I am running Timber framework on a Wordpress site and in my twig file I have the following code:
<div {{ fn('post_class', ['cell', 'small-12', 'medium-6', 'large-' ~ productTabW, 'xlarge-' ~ productW] ) }}>
On one server it outputs the correct:
<div class="cell small-12 medium-6 large-8 xlarge-6 post-66840 product type-product status-publish has-post-thumbnail product_cat-... ">
On another server I get this:
<divclass="cell small-12="" medium-6="" large-8="" xlarge-6="" post-66835="" product="" type-product="" status-publish="" has-post-thumbnail="" product_cat-....>
You will note the space is removed between the div and class and it looks like the array is expecting key value. The code is the same so I am wondering what php configuration would make Timber output this behaviour.
This was a problem with an outdated Timber installation for PHP 7.4. Updating Timber through composer solved the issue.
Related
in a form i would like modify my url when i change my select option.
When i do this, i have this in my url :
?extension-filter=&extension-list=1019
And i try to get 'extension-list' for give this parameter in my path.
Something like this is possible ? :
<form action="{{ path('my_path', {myoption : app.request.attributes.get('_extension-list') }) }}
You can retrieve a param in query string as follow:
app.request.get('_extension-list')
Hope this help
I was just going through the bolt template for _recordfooter , in the default theme and came across the following liens of code:
{{ __('general.phrase.written-by-on', {
'%name%': record.user.displayname|default(__('Unknown')),
'%date%': record.datepublish|localedatetime("%A %B %e, %Y")
}) }}
I am not quite understanding what the above line of code is really doing and most of all i am not understanding what the usage of the double underline function and also what exactly is 'general.phrase.written-by-on' and where is it coming from ??
They are keyword in the base translation file, in the loacle specific directory under vendor/bolt/bolt/app/resources/translations/
I'm using keystone.js with twig.js as template language. how can i change locale in date?
http://keystonejs.com/docs/database/#fieldtypes-date
I looked through all issues and stackoverflow questions and didn't find answer. in my template i write
{{ post._.publishedDate.format('D MMMM') }} and output is 9 July. I want it to be 9 июля in russian locale.
As far as I know, KeystoneJS use moment.js to set format on date. But how can i change momentjs locale? should i do this on my template or keystone.js or somewhere in middleware or keystone.js file?
I have tried this:
{{ post._.publishedDate.locale('ru').format('D MMMM') }}
{{ post.publishedDate.locale('ru').format('D MMMM') }}
{{ post._.publishedDate.format('D MMMM', 'ru') }}
{{ post._.publishedDate.format('D MMMM', 'ru') }}
{{ post.publishedDate.parse('Do MMM YYYY') }}
{{ _.format(post.publishedDate, 'D MMM') }}
Also i tried in keystone.js file set local variable moment = require('moment') and then in template
{{ moment(post.publishedDate).locale('ru').format('D MMMM') }}
And it didn't work too. What I'm doing wrong?
I can't understand how KeystoneJS work with momentjss and what should I do.
this documentation part is not very helpful.
I think you can set default language for whole site as.
// keystone.js
var moment = require('moment');
moment.locale(locale);
The quality of the item excerpt of a search result seems to differ between Magnolia 5.4.1 CE and 5.4.3 CE. I have the same website/pages on both system. On 5.4.1, the excerpts look good and it actually shows the parts where the keywords occurs and highlights them, whereas on 5.4.3, the excerpts does not show this but instead shows weird UUIDs and author names, that should not be visible to a public user:
The content nodes on both systems have the identical content. I pretty much use the default installation of 5.4.1 and 5.4.3 CE.
Anybody else having this problem or knows a reason for this? Is it a bug? Any way to fix this without having to write my own SearchTemplatingFunctions or ExcerptProvider?
The code that I use for the search:
[#-------------- ASSIGNMENTS --------------]
[#assign queryStr = ctx.getParameter('q')!?html]
[#-------------- RENDERING --------------]
[#if queryStr?has_content]
[#assign searchResults = searchfn.searchPages(queryStr, '/mysubfolder') /]
[#assign recordsFound = searchResults?size /]
<h3><em>${recordsFound}</em> ${i18n['search.pagesFoundFor']} "${queryStr}"</span></h3>
<div class="list-group">
[#if searchResults?has_content]
[#list searchResults as item]
<a href="${cmsfn.link(item)}" class="list-group-item">
<h4 class="list-group-item-heading">${item.title!}</h4>
<p class="list-group-item-text">${item.excerpt!}</p>
</a>
[/#list]
[/#if]
</div>
[/#if]
Thanks.
================== Update ==================
It seems to be a know bug as per https://jira.magnolia-cms.com/browse/MAGNOLIA-6245 but it is said to be fixed (in June 2015). However I still have the issue. See my comment in the Jira Ticket: https://jira.magnolia-cms.com/browse/MAGNOLIA-6245?focusedCommentId=120828&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-120828
================== Update 2 ==================
I setup a new 5.4.3 locally, where the issue does not occur. The issue still occurs at the 5.4.3 instance at my hosting provider though (about which my original posting is about). I downloaded the repo-conf, and made a diff with my local repo-conf folder, there are no differences in either jackrabbit-memory-search.xml nor jackrabbit-bundle-mysql-search.xml.
I found the solution to the problem thanks to a hint in the Jira:
https://jira.magnolia-cms.com/browse/MAGNOLIA-6245?focusedCommentId=120872&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-120872
The lines
<!-- needed to highlight the searched term -->
<param name="supportHighlighting" value="true"/>
<!-- custom provider for getting an HTML excerpt in a query result with rep:excerpt() -->
<param name="excerptProviderClass" value="info.magnolia.jackrabbit.lucene.SearchHTMLExcerpt"/>
were also missing in the file
${magnolia.repositories.home}/magnolia/workspaces/website/workspace.xml
due to some mistake at the hosting provider's template which they use for setting up Magnolia.
I started working on a project using Silex and Twig and now I'm trying to set up translations. I registered TranslationServiceProvider before TwigServiceProvider
and basically this work's:
{{ app.translator.trans('Homepage') }}
but this doesn't:
{{ 'Homepage'|trans }}
and it returns the following error:
Twig_Error_Syntax in ExpressionParser.php line 573: The filter
"trans" does not exist in "homepage.twig" at line 6
I have read the Silex documentation stating that
when using the Twig bridge provided by Symfony (see
TwigServiceProvider), you will be allowed to translate strings in the
Twig way
but I still don't understand what I am doing wrong and how does the trans filter work.
In my particular case, the issue was that I did not have, twig-bridge declared in composer.json:
"require": {
"silex/silex" : "1.2.2",
"symfony/twig-bridge" : "~2.3",
"twig/twig" : "1.16.2"
}
only silex and twig.