Sensenet: Define Content Type with File Upload - sensenet

How Can I define an content type with a field that contains an file? I think I should use binary type data to do it that but I don't know how to do the rest...
This example uses image upload, but I'm don't know how to define a field as a simple file upload...

The "File" content type is designed to upload any kind of file. In the example - what you said - described a specialized content type with image related metadata. You should try to use the File content type. If its metadata is not good enough for you, you can create an inherited content type with the desired field set.

As Zoltan has written in sensenet there is a predefined content type called File to handle any kind of file you want. If you inherit your custom CTD from this type (parentType="File") it will automatically have a Binary field to store file's binary data when upload and you can define additional fields for custom metas.
If you want to use a content type inherited differently you can use a Binary field to store any kind of data, but will lose built in upload functionality (Upload page). In the other hand on the New/Edit page there will be the File upload's Browse button beside your custom field.
With this it's important to set properly the visibility configurations. If it's set to Hide then you won't be able to upload a file from the New or Edit page.
<Field name="CustomField" type="Binary">
<DisplayName>Custom Field</DisplayName>
<Configuration>
<VisibleBrowse>Hide</VisibleBrowse>
<VisibleEdit>Show</VisibleEdit>
<VisibleNew>Show</VisibleNew>
</Configuration>
</Field>

Related

Retrieve the configuration parameter in adobe livecycle

I have set a configuration parameter containing a path in adobe livecycle process. I want that path to be reflected in a fragment source file property of an xdp. Is there a way to retrieve the value of configuration parameter in adobe live cycle designer? will it be done using javascript in designer ?
If I understand your question correctly, here is what you are doing:
In a LiveCycle process orchestration, you are reading in a configuration parameter.
You have a form with a fragment embedded in it and you would like to read in a the configuration parameter.
Your form is probably saved on the LiveCycle server.
Since the process orchestrations are called at runtime, you can't call a variable/configuration parameter during design time. If you want to read it in at runtime, I would suggest the following approach:
Add a setValue component that injects the runtime parameter into a hidden field ( if you just need to read the value and perform some calculation based on it) or a visible field.
Test your rendered from to ensure that the variable value is injected correctly into the template.
Do let me know if you have any other questions.
Thanks,
Armaghan.

Getting HTML of Smart Form Content in Ektron

I am working in Ektron 8.0.
I have created a smart form configuration in Settings,I assigned this particular smart form configuration for
a Folder and created a Smart form content.Now i am trying to access the Smart Form content programmatically.
I am getting the "XML" data as the content.Html property.Is there is any way i can get the HTML data corresponding to a smartform content,rather than these XML data?
There are a few ways to this, here are two.
XSLT:
<CMS:ContentBlock runat="server" Visible="true" DisplayXslt="/xmlfiles/SmartForm.xslt" DefaultContentID="23" />
The SmartForm.xslt file translates the xml into formatted html.
Use XSD to access SmartForm Content on the code behind.
This article explains the process.
http://developer.ektron.com/Templates/KBDetail.aspx?id=603
You need to get a copy of the .xsd file and use it to create an object definition for your smart form.
Use the xsd.exe tool to create a class. The command looks like this.
"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\xsd.exe" "C:\inetpub\site\xsd\SmartFormContet.xsd" /classes /language:CS /namespace:SmartForm.SmartFormContent
This will generate a class file named SmartFormContet.cs
Copy this file and paste into the code behind of the page.
Deserialize the XML from the Content.Html property.

File uploading from within a custom form tag in Spring MVC

Context
Part of the administrator side of our application requires the user to edit various types of content, which involves using a rich text editor or using files to generate content that can be seen by the 'client side' users of the application. It's kind of a domain-specific CMS lite.
Because this 'content' can be used in various parts of the application, it is included as a seperate relation in some of our domain entities. We decided to make our own tag library that defines some form fields that can be used to edit this content when an administrator edits an entity that includes a piece of content.
Question
What we'd like to be able to do is the following.
<form:form modelAttribute=...>
<olo:content-editor path="content"/>
<!-- Other form fields for this entity -->
<form:.../>
<form:.../>
</form:form>
The olo:content-editor tag then generates a number of form fields based on what type of content is needed. This means it may (or, depending on the type of content, may not!) generate the filebased-content tag which contains:
<input type="file" name="file/>
Which can be used to replace the file associated with the file based content.
The problem is that the Spring docs indicate that the file upload requires the form to have the enctype to define that it's sending multipart form data. As the file upload is part of the tag and not the form itself, we find this is undesirable. We would like to be able to use our olo:content-editor tag in forms without having to change the form enctype attribute. Is this possible?
Possible solutions
We can think of two client-side hacks that may resolve our problem, but both seem to be rather ugly solutions:
Include a script in filebased content tag that changes the form enctype when it's loaded, so that it is always set to the appropriate type. (Very ugly.)
Submit the file data as a regular hidden form field, of which the data is set by using the HTML5 File API (administrators use a compliant browser. This seems far less ugly but still not an optimal solution.)

Adding a custom field type to SugarCRM?

I'm trying to add a custom field type to our SugarCRM 6.2 instance. I want to add an "email link" type field. I want it to function like the URL field, but prefix every address with "mailto://" prefix instead of "http://".
It will be good if that field type is available in studio while creating new fields or in minimum, some custom code to achieve it.
What I did up to now:
- I've copied include/SugarFields/Fields/URL to include/SugarFields/Fields/Email
- In modules/ModuleBuilder/language/en_us.lang.php I've added a title for the email field
But unable to get anything working. Any help?
First of all you do not want to make any coding changes outside of the custom directory. Doing so outside of this directory is not upgrade safe.
Create a custom fields directory in your custom folder
Create new template files (.tpl) for your custom field
then you can just add a regular textfield in studio
then edit your viewdefs in your custom directory
in your tpl file concatenate the mailto:// to your text and just add the persons email address and it will take care of the rest for you
why you need custom field type for such small functionality? Just add your custom JS file in editviewdef.php. Then use some jQuery selector to perform certain action. For detail view, you can use view.detail.php to add required text in run time.
This will help you to store less data in database and display more in frontend.

how to read/parse dynamically generated web content?

I need to find a way to write a program (in any language) that will connect to a website and read dynamically generated data from the website.
Note that it's dynamically generated--it's not enough to get the source html, because the data I'm interested in is generated via javascript that references back-end code. So when i view the webpage source, I can't see the data. (For example, go to google, and do a search. Check the source code on the search results page. Very little of the data your browser is displaying is reflected in the source--most of it is dynamically generated. I need some way to access this data.)
Pick a language and environment that includes an HTML renderer (e.g. .NET and the WebBrowser control). Use the HTML renderer to get the URL and produce an HTML DOM in memory (making sure that scripting is enabled). Read the contents of the HTML DOM after the renderer has done its work.
Example (you'll need to do this inside a System.Windows.Form derived class):
WebBrowser browser = new WebBrowser();
browser.Navigate("http://www.google.com");
HtmlDocument document = browser.Document;
// extract what you want from the document
I used to have a Perl program to access Mapguide.com to get the drive direction from one location to another location. I parsed the returned page and save to database. If the source never change their format, it is OK. the problem is the source format often change, your parser also need change.
A simple thought: if we're talking about AJAX, you can rather look up the urls for the dynamic data. Then you can use the javascript on the page you're talking about to reformat this.
If you have Firefox/greasemonkey making a DOM dumper should be a simple matter.