I would like to print a block region inside a layout file. However the layout template doesnt have access to the 'page' variable. So I cannot do:
{{ page.regionname }}
Is there any code to print block regions? Oooor how can I get the page variable in one of my layouts? The layout and template file is defined in my yml file as follows:
services_overview:
label: services - Overview
category: ssld Layouts
template: templates/layouts/ssld-hs-overview
regions:
sidebar_left:
label: Sidebar Left
right:
label: Right
left:
label: Left
middle:
label: Middle
(It might be worth mentioning that I'm not too familiar with twig. This is the first time I work with Drupal 8)
You can print the regions in page.html.twig file as {{page.sidebar_left}}. Your your_theme.info.yml file should look something like this
name: Bartik
type: theme
base theme: classy
description: 'A flexible, recolorable theme with many regions and a responsive, mobile-first layout.'
package: Core
version: VERSION
core: 8.x
libraries:
- bartik/global-styling
regions:
sidebar_left: 'Sidebar Left'
right: 'Right'
left: Left
content: Content
middle: 'Middle'
Above is a sample from bartik theme info file. A.F.A.I.K content region is mandatory
Related
Line is not rendering correctly. It's rendering as instead of
My code is as follows:
LineGraph.js:
import React from 'react'
import {Line} from 'react-chartjs-2';
function Linegraph() {
return (
<div className="linegraph">
<Line
data={{
datasets:[{
type:"line",
data:[{x:10,y:20},{x:15,y:10},{x:12,y:4}],
backgroundColor:"black",
borderColor:'#5AC53B',
borderWidth:2,
pointBorderColor:'rgba(0,0,0,0)',
pointBackgroundColor:'rgba(0,0,0,0)',
pointHoverBackgroundColor:'#5AC53B',
pointHoverBorderColor:"#000000",
pointHoverBorderWidth:4,
pointHoverRadius:6,
}]
}}
/>
</div>
)
}
export default Linegraph
I'm following a tutorial here and at 1:33:17 they were successfully able to implement it while mine remained as the vertical line going straight down.
Here's also a screenshot of my project set-up:
Your help is greatly appreciated!
You could change the chart type to 'scatter' and add the property drawLine: true to the dataset.
datasets:[{
type: "scatter",
drawLine: true,
data:[{x:10,y:20},{x:15,y:10},{x:12,y:4}],
...
The Chart.js documentation states that scatter charts are based on basic line charts with the x axis changed to a linear axis.
Therefore, assuming you're using react-chartjs-2 together with Chart.js v3, you may also keep type: 'line' but will have to define the x-axis as type: 'linear' as follows:
data={{
type: "line",
...
}}
options={{
scales: {
x: {
type: "linear"
}
}
}}
We ended up getting this to work by going inside package.json and setting the following versions:
'chart.js':'^2.9.4',
'react-chartjs-2':'^2.11.1'
=)
I am using chart.js to render data passed from a Django view. I have various types of charts all working well, EXCEPT when my chart title includes as apostrophe.
For example, the title: My child's learning gets displayed as: My child's learning
The code below shows how I use the title which is the variable chart_row.heading_2 passed from the Django view
options: {
title: {
display: true,
text: '{{ chart_row.heading_2 }}'
}
}
The title works in all other instances where there is no apostrophe.
Is there any workaround to this?
OK, I found the answer was to use escapejs:
text: '{{ chart_row.heading_2|escapejs }}'
From the doc: Django built-in template tags
Try rendering the title as safe.
options: {
title: {
display: true,
text: '{{ chart_row.heading_2|safe }}'
}
}
What is the best way to have left icons rendered for list items in both lists with disclosure and lists without disclosure? I need the icon to read the image src from one of model's properties.
I currently have a simple tpl that does: {xyzmodelproperty}
Any help is much appreciated! Thanks!
You can add a more complex template to customize the look of your list item like you want. In that template you have access to all properties in the store.
extend : 'Ext.List',
xtype : 'list',
config : {
title : 'List',
layout : 'fit',
grouped: true,
store : 'MyStore',
itemTpl : '<table style="width:100%"><tr><td style="width:30px">{icon}</td>'
+ '<td>{content}</td></tr></table>'
}
Foundation default tooltips look like this:
I'd like to get rid of the small top triangle on parts of my website.
To get rid of it everywhere you just have to change the $tooltip-pip-size variable value to 0 from the foundation_and_overrides.scss file (also called _settings.scss if you're not using the foundation gem with rails).
Is it possible to define a custom version of the foundation tooltip without a pip?
EDIT
The difficulty here is that when I write something like
<span data-tooltip class="has-tip tip-bottom" title="Here are my tooltip contents!">extended information</span>
Foundation javascript generates a specific element at the end of the document containing the actual tooltip:
<span data-selector="tooltip8vxaud6lxr" class="tooltip tip-bottom" style="visibility: visible; display: none; top: 78px; bottom: auto; left: 50px; right: auto; width: auto;">Here are my tooltip contents!<span class="nub"></span></span>
You see that the tip-bottom class I added to the first span got copied to the second but that is only the case for foundation specific classes like tip-left, tip-right and so on.
What I would like to do is being able to add a "no-pip" class to the first span (the only one I actually write) and be able to alter the look of the generated span containing a "nub" element.
<span data-tooltip class="has-tip tip-bottom no-pip" title="Here are my tooltip contents!">extended information</span>
Just hide it by setting display property to none
.tooltip > .nub {
display: none;
}
that little triangle is just span with class nub all what you need to do is to remove the css border from it then you 'll have your tool tip in the same location as normal without the little triangle
With foundation version 5 you can customize the tooltip template.
Just remove the <span class="nub"></span>:
$(document).foundation({
tooltip: {
tip_template : function (selector, content) {
return '<span data-selector="' + selector + '" class="'
+ Foundation.libs.tooltip.settings.tooltip_class.substring(1)
+ '">' + content + '<span class="nub"></span></span>';
}
}
});
the controller looks like this
class App.ContactsController extends Tower.Controller
index: (params) ->
#set('person', App.HighrisePerson.create())
#render "index"
the view looks like this
App.ContactsEditView = Ember.View.extend
templateName: 'contacts/edit'
resourceBinding: 'controller.person'
init: (args...) ->
#._super(args...)
console.log(#.get('resource'))
console.log('inited')
with the above block i see in the console that resource is set to an instance of my Ember.Object
but with the following viewcode
div class: "row-fluid", ->
text "{{#with resource}}"
text "Hello"
text "{{/with}}"
relevant part of parent view
div class: "row-fluid contact-form", ->
div class: "row-fluid", ->
h1 "Want to work with us?"
p "So...you want to be kohactivated!?!? Please take a few moments to fill out the form below and provide us with some details about your project, company or start-up."
text "{{view App.ContactsEditView}}"
i see no rendered output for hello
if i move hello outside of the #with block i see hello,
so I assume that it isnt recognizing resource for some reason
Any help is appreciated.
That's right -- it's looking for resource in the current handlebars context rather than the view (which as of ember.js 0.9.8 I believe, is no longer the default context). You'll need view.resource instead.
(Side note: conversely, to reference the handlebars context from the view, use context.whatever)