We have multipage forms built using the webforms module. On any page numbered greater than 0 we want to hide the node content. This content can be quite long and doesn't need to display on each page of the form.
So I've added a custom module and added to it...
/**
* Implementation of hook_form_alter().
*/
function bmc_customisations_form_alter(&$form, $form_state, $form_id) {
//dpm('form state page_num is '.$form_state['values']['details']['page_num']);
//hide node body on multi-page forms if not first page
if ($form_state['values']['details']['page_num'] > 0) {
//dpm($form);
dpm($form['#node']->body);
$form['#node']->body= '';
dpm($form['#node']->body);
}
}
I can see that $form['#node']->body is being replaced with my empty string but the displayed page still has the body text. So I guess the node is built and then the form added to it.
Am I running a fool's errand?
User vernond on the drupal site pointed out that it is possible to simply use a markup field on page 0 instead of node content and that text will then only appear on page 0. Simples!
Related
On my lotus domino web application, I have customized search form where user can enter criteria (around 10 criteria ) is there, now what I would like to do is that I would like to throw the result to another page/form using html.
But my concern is that I would like to access div elements on the output form/page and I am not sure if I can do it Web query save agent of search form.
Basically what I wanted to do is I will compose html in the WQS agent and assign that HTML to div of the output search form. but I am not sure how to access div element of the another form using WQS agent of the current form.
I can display result in the same form but question would remain again how to access div element in the WQS agent of Lotusscript.
using document context we can access the field of the currrent document submitted but not sure about div element.
Please asssist
You could use some REST here. Basically submit the search form to a REST service, collect the results and render them as needed.
In short, all you can do in a WQS is to spit out a stream of text (which may or may not be HTML) from the server to the browser. So I think you have a couple of options:
In your template HTML, add a placeholder where your <div> is and do a replace() (replace the placeholder with the HTML you want to appear in that div) before sending out the HTML to the browser, or
Output enough JavaScript and/or JQuery and/or whatever so that the div is updated by the client after the document is loaded. Of course there's no guarantee that will happen though.
Another approach is just to create a Notes document with computed fields and/or computed text. In this case you don't think of updating the "div" as updating an HTML div, you're updating computed text on a Notes form. When you return the document to the browser as a document instead of messing with a WQS agent.
I suppose your WQS agent could also potentially send out just JavaScript to update another page, but to me that smacks of a cross-site scripting attack.
My use case is: a user goes onto a webpage and modifies it by either filling in a form, populating the page with data from the database, or dragging around some draggables on the page. He can then download the page he modified as pdf. I was thinking of using PhantomJS to do the conversion from html to pdf.
I understand the basic functionality of PhantomJS and got the basic example working but in all the examples I've seen, either a local file or a url is passed in. Example:
page.open('./test.html', function () { ... }
How would I render the page that is getting modified by a user using PhantomJS? I have 2 ideas:
Have the url change as the user modifies the page, and simply pass in the url. For example, the url contains the position of a draggable div.
Send the modified html to back-end, save it, and run PhantomJS
Do these solutions make sense? I'm hoping there would be a simpler way.
I'm trying to work out a way I can add my H1 and byline markup to my Root master page and then have all the pages underneath fill these fields in. I'm using the Portal Engine development mode.
The H1 and byline are in a different web part zone to the page placeholder. They are showing on all the pages under my root node but I can't find a way to make populate the title or byline on those pages.
I've tried a few things:
- editable text web part - but this is only editable on the Root node and not the pages underneath
- I thought maybe I could use <%# Eval("Byline" %> and add this as a field to the Page type but that doesn't show through either.
Is there any way to include something in the master page that is dynamically filled in (or editable in the designer) on all pages under the root node? Or do I need to move myH1 and byline out of the master page and include in every template that my pages use?
You can add additional field to your page type named 'Byline'. This field will be editable on Form tab of each page. Then you can include some viewer web part like Document Viewer or repeater. Then configure Path like './' (it means to display information for current page). And add transformation where you cat do something like <%# Eval("Byline") %>.
Or alternative way is to use static html web part and add macro there {%CurrentDocument.Byline%}.
You can do it using macros: add a static text web part on your master and set text property to :
<h1>{%CurrentDocument.DocumentPageTitle#%}</h1>
or
<h1>{%CurrentDocument.DocumentName#%}</h1>
depending on where you keep your page title.
I'm trying to create a CSS documentation library in Orchard. I want to save a description, CSS snippet and HTML snippet against each content type. The first view would show the description and CSS and HTML code written out. The second view would show a preview of what the CSS and HTML look like rendered.
cssdocumentation.com/content/item1
cssdocumentation.com/content/item1/live-preview
I've created the content type and the first view. But I'm not sure how to create the second view. I can see if I can create the alternative URL I can use the Url Alternates module to create an overriding .cshtml
To create an alternative URL I've looked at the autoroute module but this only allows you to adapt a single URL (unless I'm missing something?) and I've looked at Alias UI but this forces me to manually create an alternative URL everytime I create a content item.
Is this possible in Orchard without writting too much C#? (I'm a frontend developer so I only dabble in the behind the scenes stuff)
Thanks for any help
Best solution is to do this within your own module. But as a secondary option instead of having a second page, combine this content with your first page and hide it with CSS. When the user clicks a button to navigate to the next step render the CSS/HTML result on the same page. You can do this in many ways, here are a few ideas:
Render the CSS/HTML result out straight away on the same page but hide it. Show it when the user clicks a button
using jQuery to render the result on the client side. More dynamic if you allow editing of the HTML and CSS.
Redirecting the user to the same page with specific url parameters which you can pick up in your alternate to modify the output.
I have a code that creates a teamsite. After that I add some web parts to wiki web part zone(rich content area). In SharePoint 2010 user can change a text layout of the rich content in page edit mode.
Is there any way to programmatically change the text layout of the rich text area? I would want to set "two columns with header"-layout after site creation has completed.
My site is created like this.
site = elevatedSite.SelfServiceCreateSite(params.....);
rootWeb = site.RootWeb;
rootWeb.ApplyWebTemplate("STS#0");
SPListItem currentItem = rootWeb.Item;
var xhtml = currentItem[SPBuiltInFieldId.WikiField] as string;
Now I can modify the xhtml string and save it back to the page. I have tried to change it so that it contains exatly the same html structure which have created by sharepoint itself, when changing the text layout. After that change, actually it is not recognized as "two columns with header"-layout in sharepoint. It is still default one-column layout. Is there anybody who knows is it possible to change the text layout of the rich text area programmatically?
I found answer from here http://donalconlon.wordpress.com/2010/05/04/sp2010-creating-a-wiki-page-using-the-om/. SharePoint stores the information about used layout to the hidden span-element in wiki page.
For example, this presents two column layout without the header or footer.
<span id="layoutsData" style="display: none">false,false,2</span>
first false = no header
second false = no footer
2 = two columns
I have been looking for some information on doing the same thing. I found this blog post that checks out the page, edits the content then publish and approves it.
SharePoint 2010 change page content data through Object Model / API – Console Application
If you need to modify pure HTML content, its better to use cutom IHttpHandler (wrapped in dll) and connect it to SharePoint via web.config. Is is also allowing to modify dynamic content like AJAX responses.