Store DisplayChildren(model) in string variable for later modification - orchardcms

In Orchard i can see the menu is output in MenuItem.cshtml with the line DisplayChildren(model).
I would like to take this html output and run an xslt transform to change the structure.
How can i get the menu item as the html and store this in a local variable (as opposed to it being output directly to the stream)?

var html = DisplayChildren(model);
Yup, it's that simple. It will give you a IHtmlString, that you can ToString() if you need to. But xslt? 8|

Related

JODIT displays content with html tags after editing in React js

I am working with Jodit editor on a react project. When I create a note and send to database, and displays the note, it displays fine, but when I try to edit the content and save, the rendered text/content now contains some html tags and this "<p><". I have tried using renderHTML to convert it to only plain text, but that doesn't seem to work. I really need help on converting to plain text alone. The render renderHTML works fine when creating a new note, but doesn't convert to plain text when I try to edit the content.
Before you use the Jodit contents in a non-Jodit environment, you'll need to use a utility that converts the HTML tags.
One library that does this already is html-to-text.
On the backend, the actual code is as simple as
const { conversion } = require('html-to-text');
let adjustedText = conversion('<p>Your string of HTML code here</p>');
... unless you want to feed optional parameters to the conversion() function, like wordwrap. See html-to-text documentation for that.

How to divide web pages in blocks with sailsjs

I am starting developing with Sailsjs and I would like to know how to divide a webpage into differents blocks.
for example :
in layout.jade i have
doctype html
html(lang="fr")
head
body
div(class='container')
div(class='row')
div(class='col-md-12')
block header
h1 header
div(class='row')
div(class='col-md-8')
block content
div(class='col-md-4')
block right
block footer
then in my controller1/index.jade i have
extends layout
append content
p
some content
So when I type http://myserver.com/controller1/index in the browser, it works.
How to append some code in the block right form the result of another controller ? (I don't want to append some code to the block right directly in the controller1/index.jade file, to make the file as shorter as possible).
So I guess we can call another method of the controller inside the jade file ?
For example i would like to put a code like :
append right
=call('controller2/action1')
at the end of the controller1/index.jade file.
The purpose of my question is to figure out how divide the html parts of a webpage like we can do it with php using include method (for example).
Thank you
Benjamin

How to get HTML value from XElement?

The XML file that I am trying to parse has an element that may contain HTML. I try to get the value like this:
data.Description = root.Element(namespace+ "Description").Value;
But when the value is HTML, I get back the plain text representation of the HTML. Is there any way to get the original value of XElement?
You're looking for .ToString(), which returns the outer XML source (including the tag itself)

JSF Renderer - Store encoded output in string for relocation

I would like to store the response generated by the encodeAll() method of a UIComponent into a string to use the content somewhere else.
I alread tried to set up a FacesContextWrapper which provides a special ResponseWriter that should write the content to a StringWriter, but it does not work. It seems my ResponseWriter is never called.
I know there is the other way and encode in the right place and probably I will do so, but I would still like to know how to do that. Especially the compression of the content, there should be no spaces between tags and no linebreaks, is very important.
EDIT:
I have some facets and the content of these is used to be passed to javascript, because of that i would need the rendered content of the facets to be compressed to a single line.
First i tried to wrap around the writer to get the content, then compress it myself and append it to the javascript as parameter, but it didn't work.
Now i render the content at the right place, but it's not compressed to a single line.
EDIT2:
Javascript Strings can only be multilined if "\n\" is used at the end of the line. I can't change the content produced by the encodeAll() method so it's really hard. I really will have to capture the content that is generated and then manually compress the string! But how to do that? ResponseWriter-wrapping did not work for me.
SOLUTION:
I would like to share my solution with others!
ResponseWriter offers a method called cloneWithWriter(Writer w) which i didn't know. By using this method with a custom StringWriter implementation you can capture the output in a buffer and finally use that buffer as string

Formatting views template output

I am using this code in a views template to print user name in a field. The output is fine except it doesn't shows as a link, as its supposed to.
<?php print $row->users_name; ?>
How can i modify the code to show the output as a link? btw this was the comment in the template file which i cant decode.
Variables available:
$view: The view object
$field: The field handler object that can process the input
$row: The raw SQL result that can be used
$output: The processed output that will normally be used.
When fetching output from the $row, this construct should be used:
$data = $row->{$field->field_alias}
What does a dpr of $row->users_name show? Is it supposed to contain the correct HTML for a link?
If not then take a look at the l function - http://api.drupal.org/api/function/l
Like Martin says you should let us know where you want the link to point to.

Resources