To set the language for JS Timeline one must add this line inside the createStoryJS in the apps scripts.js :
lang: "de"
How would you go about having this set automatically to the current DNN Language?
Thanks
A quick solution would be to have some server side code like
Pseodo code:
<script>
var langPage = "#Thread.CurrentThread.CurrentCulture";
</script>
now you have the languge in your JS, and can re-use it.
Related
In my application, I am using Angular UI bootstrap with AEM and having the sightly parameters in the same.
The issue is, when I try to access the sightly parameters inside the script tag of UI modal It is not rendenring the sightly parameters.
< script type="text/ng-template" id="/view2.tpl" data-sly-include="template.html">
${properties.title}
< /script >
This specific problem is there with Sightly with AEM and angular. Can anyone suggest how to make a Modal work for Angular+AEM+sightly?
Help will be highly appreciated.
As per the specification, using data-sly-include will cause the content of the <script> tag to be replaced with the content of the included script.
If you want to use HTL/Sightly templates from template.html you should instead write data-sly-use.tpl="template.html"
First, for using templates, use the data-sly-use instead of data-sly-include.
Second, HTL (Sightly) escapes the expressions by default depending on the context where they are used. You can explicitly specify the context using the context option as shown below.
<script type="text/ng-template" id="/view2.tpl">
<!--/* Use scriptString if you are using the value as a string */-->
${properties.title # context='scriptString'}
<!--/* In case you are trying to output an entire function or javascript,
there is no context specifically available for that. So, you can use the
unsafe option to disable escaping completely */-->
${properties.title # context='unsafe'}
</script>
More information on Display Context can be found here and information on Template and Call here.
I'm trying to implement a disqus counter following this official tutorial in my angular application. But I can't see any number, all that's displayed is "First article" which is the text in the span element that should be replaced with the counts if I'm getting it right.
1) I've added the count.js in my index.html right before the body closing tag (and used my site's name, not an example like here):
<script id="dsq-count-scr" src="//mysite.disqus.com/count.js" async></script>
2) As I'm using Angular UI Router I guess I shouldn't use counts for links but rather an identifier:
<span class="disqus-comment-count" data-disqus-identifier="test">First article</span>
3) The identifier is also specified in the config:
this.page.identifier = 'test';
As my language settings specified in the config get applied I believe the config is initiated.
Does anyone know what I'm doing wrong here?
I'm trying to use react.js in Hugo. I know Go template variables are accessible in HTML file.
My question is how to access them in javascript. or is there a workaround?
thanks in advance.
UPDATE:
currently my workaround is to use meta tags in HTML and load Go template variables like this:
<meta name="title" content={{.Title}} />
and then in javascript,
function getMetaTitle() {
var metas = document.getElementsByTagName('meta');
for (i=0; i<metas.length; i++) {
if (metas[i].getAttribute("name") == "title") {
return metas[i].getAttribute("content");
}
}
return "failed to access...";
}
var metaTitle = getMetaTitle();
but this way is inconvenient when the number of meta tags growing, is there a more concise way to do this?
I doubt Hugo and React is a good pair but that's off topic and I might be wrong about that. You are asking, how to get Hugo variables into website's JavaScript. My answer:
Hugo is static website engine, so it only converts templates and markup documents (with your content) into HTML files. Now, when you upload your files onto your server, your JS cannot see anything Hugo — only your files.
The question becomes, how to transfer Hugo variables into some files of your website.
As you suggested, it's best to write variables into your HTML (or JSON) using Hugo, then read them by JS. If it's small amount, use attributes or tags. If there's a lot and it doesn't differ per-page, use a separate JSON file.
For example, personally I have a multilingual site which a) requires different language titles to appear dynamically via JS; b) uses JS which queries different Lunr.js search indexes in JSON format.
For both I use data-<name> attributes:
<section class="section-search" data-index="{{ .Site.BaseURL }}searchIndex.json" id="section-search">
<input type="search" id="search-input" placeholder="{{ ( index $.Site.Data.translations $.Site.Params.locale ).dataloading }}" data-loaded="{{ ( index $.Site.Data.translations $.Site.Params.locale ).dataloaded }}">
<!-- search button goes here -->
</section>
For example, on English templates (rendered into /public/), data-loaded attribute would be in English, but for Lithuanian templates (rendered into /public/lt/), data-loaded attribute would be in Lithuanian.
I wouldn't worry about "growing meta tags", but you could maybe write variables into a JSON file and then read it in JS if you are concerned about HTML bloat?
I'm building custom JSON first as HTML, then minifying/renaming it into JSON when building indexes for Hugo Lunr search as per this recipe. Instead of "baking in" the content with range as in mentioned recipe, you could simply list all the variables.
By the way, I'm using npm scripts as a build runner (instead of Grunt/Gulp) so I use json-minify:
"index:prepare": "json-minify public/json/index.html > public/site-index.json",
You could "bake" JSON files with any content (including Hugo template variables) via Hugo this way. Hope it helps.
You can specify a custom output format for Javascript within your config.toml so that Hugo then treats those particular formats and file extensions like it's content files where it replaces the template variables with adequate values.
So, an entry such as below in your config.toml will treat javascript files as one of the media type it needs to consider for its custom output formats:
[mediaTypes]
[mediaTypes."application/javascript"]
suffix = "js"
You can read more about it here
You can, of course, inline your JS in your layout files, but that is probably not what you want.
There have been some discussions about improvements in this area on the Hugo discussion site, but nothing concrete yet.
I'm building a DotNetNuke module and I need to include the html editor. However, my modules are in a stand alone solution that xcopy's to my DNN install (I'm following the Visual Studio project templates for making modules). All the sample code I've seen references the text editor like so:
<%# Register TagPrefix="dnn" TagName="TextEditor" Src="~/controls/TextEditor.ascx" %>
<dnn:TextEditor ID="txtDescription" runat="server" Width="100%" Height="300px" />
The problem is that since the modules are being developed outside of DNN, the reference to TextEditor obviously breaks the build.
Plan B was to instantiate the editor dynamically through a placeholder control like so:
EditorProvider editorProvider = new EditorProvider();
var control = editorProvider.HtmlEditorControl;
control.ID = "txtDescription";
phEditor.Controls.Add(control);
This kind of works, but most of the toolbar buttons are messed up!
DNN Editor bug
Any help would be greatly appreciated!
After some swearing and headbanging, I found the easy answer of just instantiating the usercontrol instead of the editor server control.
var control = this.LoadControl("~/controls/TextEditor.ascx");
control.ID = "txtDescription";
phEditor.Controls.Add(control);
I am assuming you are developing a custom module for dotnetnuke, you can look at the example implementation in blog module source code on codeplex.com. EditEntry.ascx is the control that contains the same example.
Basically, You just need to reference DotNetNuke.dll and DotNetNuke.WebControls.dll to make it working inside ascx declaration.
Found a better answer at http://www.dnnsoftware.com/forums/forumid/203/postid/466819/scope/posts
from Hristo Evtimov.
His method lets you add attributes to the Text editor.
His code:
One way to do it is like this:
DotNetNuke.UI.UserControls.TextEditor editor = (DotNetNuke.UI.UserControls.TextEditor)LoadControl("~/controls/texteditor.ascx");
editor.ID = "Editor1";
this.Controls.Add(editor);
My code in VB.NET came out like this:
Dim txtDescription As DotNetNuke.UI.UserControls.TextEditor = DirectCast(LoadControl("~/controls/texteditor.ascx"), DotNetNuke.UI.UserControls.TextEditor)
txtDescription.ID = "txtAOneDescription" & intControlCounter.ToString
txtDescription.HtmlEncode = False
Im using the WebBrowser control to launch and browse some html files loaded locally in the windows phone 7 emulator and device. All works fine until a web page navigation with a query string us used. The javascript needs to read these query strings but the navigation totally fails when the query string is included. The navigation works fine without the query string.
Im big time stuck on this and would really appreciate your thoughts.
Tony
I too can't find a way to pass a query string to a local HTML file. (I copied the HTML file to Isolated Storage and viewed it from there.)
However...
I can successfully navigate to a local HTML file and specify a fragment. And it even works if the fragment includes equals signs (=) and ampersands (&) so you can do this:
webBrowser1.Navigate(new Uri("index.html#123=abc&456=def", UriKind.Relative));
And get the value with the following
<html>
<head>
<script type="text/javascript">
function onLoad() {
fs.innerHTML = document.location.href.split("#")[1];
}
</script>
</head>
<body onload="onLoad()" >
<p id="fs" />
</body>
</html>
to display the following on the page (in the browser control).
123=abc&456=def
(Obviously you could do something more appropriate with the value in javascript as necessary.)
Yes, you can just use the fragent like the querystring.
This, obviously, works fine as long as you don't need to use both.
You need a webserver if you pass a querystring.
This is because the browser does not know what is a query string in difference of another file. It only thinks the file is named "file.html?param=value" search this file and does not find it locally.
So locally without a webserver it is impossible.
Solutions
Spawn a tiny webserver locally.
Hack some js to know when it is local and replace all links with query string to hashtags