How can add some values into beginBody() Yii2? - yii2-advanced-app

How can I add oncopy="return false;" into html <body> in Yii2
body is initialized with the help of $this->beginBody(), how to add some values in?
in the end it should be <body oncopy="return false;">

Related

add new attribute on html through xslt

Let's say I have a ditamap file.I have published into html5.after published let's say my html file look like
<body id="SampleTopic">
<h1 class="title topictitle1" id="ariaid-title1">Sample topic</h1>
<div class="body">
<p class="p">some<strong class="ph b">bold</strong><span class="ph special">text</span></p>
<div class="p">
<dl class="dl">
<dt class="dt dlterm">Term</dt>
<dd class="dd">Defination</dd>
</dl>
</div>
</div>
</article>
</body>
here in Html file, I want to add some new attribute on the body element like
<body id="SampleTopic" class="test">
so can anyone help me with how to solve this????
can I add some plugin, if yes how to write the code???
If all you need is the HTML #class attribute, then there's no need to develop a custom plug-in.
You can just specify a value for the #outputclass attribute on an element in your DITA source files, and the value will be passed to the HTML #class attribute in the output.

How do I create links(or pass any other html/jsx) into the label of the Material-UI <Checkbox ... label="string"/> component

I'm looking for insight on how to pass custom jsx into the label of the Checkbox component.
<Checkbox
label="I accept the Terms of Use & Privacy Policy"
/>
Ideally what would render as the label is "I accept the [Terms of Use] & [Privacy Policy]" where the items inside the brackets are links.
Thanks in advance for any help!
You can pass in other jsx nodes into the label property. In this example I am using the React Router link but you could of course use an anchor element.
<Checkbox
label={
<div>
<span>I accept the </span>
<Link to={'/terms'}>terms of use</Link>
<span> and </span>
<Link to={'/privacy'}>privacy policy</Link>
</div>
}
/>
You can use html in the label property. But you'll have a problem : the component is "covered" by a transparent input which will handle every click. So links or onClicks won't work. Before the library developers resolve the problem, you can use :
<Checkbox id={uniqueId}
labelStyle={{ zIndex: 3 }}
label={(
<label htmlFor={uniqueId}>
blah blah
<span onClick={this.myAction}>yeah</span>
<a>...</a>
</label>
)}/>
Details here => https://github.com/callemall/material-ui/issues/5364
<html>
<head>
</head>
<body>
<form method="post" action="demo_form.php">
I accept the Terms of Use & Privacy Policy
<input type="Checkbox" name="terms">
</form>
</body>
</html>
demo_form.php
<?php
echo 'Hello ' . htmlspecialchars($_POST["terms"]) . '!';
?>

Polymer data bind without dom-bind

I have a polymer element <my-element> with a computed property myProperty. I need to bind myProperty to another place in the HTML page, so I can't put it inside a dom-bind template
Here's what I mean
<html>
<body>
<div>
<my-element my-property="{{myProperty}}"></my-element>
</div>
<!--somewhere deep inside another part of the document-->
<div>
<h4>myProperty = </h4><span>[[myProperty]]</span>
<div>
</body>
</html>
I cannot wrap my-element and the usage of [[myProperty]] in a dom-bind template as this would result in nearly the entire document being enclosed in this. Attempting to use the bind as it is results in myProperty = [[myProperty]] being displayed, not the value of [[myProperty]].
Is there some way to have behaviour similar to data binding but usable across the whole HTML document? (In the future there might also be a case where [[myProperty]] is used inside an attribute such as <my-second-element my-property="[[myProperty]]">). Or if both occurences are wrapped individually in dom-bind templates is there some way to make the bind global?
Thanks in advance
Not sure why you wouldn't be able to do like this:
<head>
...
<script src="bower_components/webcomponentsjs/webcomponents-lite.js"></script>
...
</head>
<html>
<body>
<template is="dom-bind" id="app">
<div>
<my-element my-property="{{myProperty}}"></my-element>
</div>
<!--somewhere deep inside another part of the document-->
<div>
<h4>myProperty = </h4><span>[[myProperty]]</span>
<div>
</template>
</body>
</html>
This is totally doable. If myProperty changes inside my-element it would also change in "this" html-document. There also wouldn't be a problem adding your second element:
<my-second-element my-property="[[myProperty]]">
Unless you're missing to tell us some specific behavior that you want, this should be what you want. :)

EJS - pass variable when include

I'm using ejs in backend with nodejs.
I'd like to pass variable when include. When include the header, pass the page title.
index.ejs:
<% include header %>
<body> . . . </body>
<% include footer%>
header.ejs:
<html lang="en">
<head>
<title><%- my_tytle %></title>
</head>
footer.ejs:
</html>
How to pass my_title in the include command?
You can pass the object inside the include statement
<%- include("header",{title:"your_title"}) %>
you can pass my_tytle directly to the index.ejs and if there is a partial view for header, my_tytle should be accessible to the header.
for example:
index.ejs:
<% include header %>
<body> . . . </body>
<% include footer%>
header.ejs:
<html lang="en">
<head>
<title><%- my_tytle %></title>
</head>
now from node server if you pass the value for my_tytle to index.ejs, like this:
res.render('template_file.js', {
my_tytle : "Value for your title"
});
then your partial view (i.e header in your case) would be also able to access that variable.
As asked somewhere in the comments, we can also use a variable to be controled by a server, and here is how:
<%- include("header",{my_tytle :`${myVar}`}) %>
<%- include("header", locals) %>
All variables that are accessible in index will also be available in header.

GWT, RootPanel.get() is null

I'm following a beginner's tutorial at http://www.tutorialspoint.com/gwt/gwt_style_with_css.htm.
The code for the HelloWorld.html file is:
<html>
<head>
<title>Hello World</title>
<link rel="stylesheet" href="HelloWorld.css"/>
<script language="javascript" src="helloworld/helloworld.nocache.js">
</script>
</head>
<body>
<div id="mytext"><h1>Hello, World!</h1></div>
<div id="gwtGreenButton"></div>
<div id="gwtRedButton"></div>
</body>
</html>
In the HelloWorld.java (extending EntryPoint), I have:
RootPanel.get("gwtGreenButton").add(Btn1);
RootPanel.get("gwtRedButton").add(Btn2);
The 2 lines: RootPanel.get() always result in null. I don't know what happen, what to check? (too bad the site doesn't have a comment/discussion section)
Thanks.
Docs says
RootPanel.get(java.lang.String id)
Gets the root panel associated with a given browser element.
DOM.getElementById(java.lang.String)
Gets the element associated with the given unique id within the entire document.
Try with
com.google.gwt.user.client.DOM.getElementById("gwtGreenButton");
com.google.gwt.user.client.DOM.getElementById("gwtRedButton");