Allow the user to upload a document to the application - c#

Using Orchard CMS V 1.6 I would like to implement a feature which (1) allows the user to upload a document (2) stores the date it was uploaded (3) Stores the id of the record uploaded
Is there a part for doing this.
I've no idea how to go about this....any suggestions welcome...thanks
EDIT
As I'v said i've used your advice to create a content type.
Then created a custom form and tried to add that content type(the media) to a custom form.(as explained on the link you provided http://devdirective.com/post/160/how-to-create-custom-forms-in-orchard-cms-with-email-and-recaptcha)
however when it appears on screen on the front end the mediaPicker box appears but it is greyed out and doesnt allow me to select it. 'Browse' and 'clear' also do nothing....Also how can i remove the option of the permalink
thanks

Create a new content type with whatever name you want eg. MyFileUpload
Add the Title, AutoRoute and Common part (common part will store the date the content item was created)
Add a field and select the Media Picker Field (you can limit extensions to only allow .doc files if you wish and make this field required)
Something like that should work :)

Related

How to build custom rich text editor in sitecore including Associated Content Select popup

I need to modify Rich Text Editor in sitecore to provide a button or something like that to add the Associated Content Select option. Could it be possible and in affirmative answer how to need starting
Thanks a lot
Firstly what your trying to achieve does not seems right for me. As associated content(Web Edit Button) sets the datasource of a rendering/sub-layout. you are trying to add that to RTE.
But below is approach you need to take to add a new webEdit button to RTE.
you need to find out what type of RTE you are using for your website. If you have not changed sitecore's default one, you can find it in core database in below path
/sitecore/system/Settings/Html Editor Profiles/Rich Text Default
if you change it you can find the core database item path under this setting in /sitecore/admin/showConfig.aspx
<setting name="HtmlEditor.DefaultProfile" value="/sitecore/system/Settings/Html Editor Profiles/Rich Text Custom"/>
To add a new web edit button you need to create an item with template id ({02404208-46D4-49BF-988B-EB363A52A1C9}) or name WebEdit Button under below path:
/sitecore/system/Settings/Html Editor Profiles/Rich Text Default/WebEdit Buttons
Once you added that you need to fill fields as below:
Click: webedit:setdatasource
Type: Datasource Menu

Include hyperlinks in description of phone call entity

My code generates a phone call activity in each customer lead, then records the SMS conversation between that customer and the company. The description may contain an URL to an image that the customer finds relevant.
I can put the URL as text in the description property, but I would like to transform it to a hyperlink (something like an <a> tag of html.) That way I can click to open it directly instead of copy pasting the URL first.
How can I achieve this?
The description field on a phone call is just a plain old text field, so you can't add any formatting or hyperlinks there.
You could make a separate field, single line of text, with a type of URL. Then the URL you input should act as a typical hyperlink.
The data types are documented at Create and Edit Fields.
I believe you're asking about being able to have a large text area, within CRM, that is editable, but allows you to enter, or at least click on, hyperlinks.
I see two supported solutions, but both would take a lot of customization.
Create an HTML webresource that loads the text from the field, parses it, looking for hyper links, and then add's the correct <a> tagging in order for the links to be clickable.
Search for a client side wiki markup Text Editor widget of some sort (possibly something like http://goessner.net/articles/wiky/ ?), and then format the hyper links with the correct markup.
None of CRM data types support native full blown html rendering. If you try to use JavaScript to update the value and try to render it as html, it would trigger a save to the database as CRM would see the attribute value as modified.

.net textbox with user added fields

I would like to create a control class that would allow the user to type text like a normal text box. However, it should have a "mail merge field" functionality that would allow the user to insert a field from a list. This field would then be identified at a later stage for population. E.g.
Your order was processed by sales_person and will be sent on date.
In the above example, the user typed "Your order was processed by " and selected sales_person from a list of fields. This list would be another control, such as a list box, so this control class would have something like an insertField method that could be called.
At a later stage, that field would be populated so it would have to be identifiable in the code. Also, the user should be able to save and retrieve this phrase with its fields.
This UI is very similar to the building of a mail merge document in MS Word.
Can anyone offer advice and/or resources to achieve this. I'd rather build my own control than use a third party, but I need guidance.
Thanks very much.
Try to use System.Windows.Forms.RichTextBox, it will allow you to markup the placeholders by using the Find() function, and then change SelectionFont, SelectionColor or SelectionBackColor

How to highlight an HTML content and save it to the database as per user for future loads

I'm trying to highlight the selected text contents by the user inside the HTML page.I have highlited the text using jquery (dot net). Now I need to save some information to the database that makes me able to highlight the same contents again for future loads of the same page, taking care of all inner elements that the text could have inside.
i.e.,
Have a base HTML files thats same for every user, given the freedom to user to highlight content in provided page, after he highlites, information needs to saved to database against each user, so that when user open the same html file again,(HTML files shown in a panel) he gets the same page with the highlighing he had done earlier.
Please suggest what information should I save to database..
any pointer how would I move ahead..
Thanks in advance your help.
not a dot net expert , but it seems like you are storing content in database, when fetching they need to be highlighted.
the best way is save content as html or write you own highlight tag
and then replace it to blank when highlight not needed , and replace it with
<div style="background-color:red"> to highlight.
Hope you are getting the approch.
And if you are using HTML files , then it is always better to store them in database. String manuplation for every request will be much heavy task to do.

How do I emulate Content Editor's Remove Links option when deleting an item?

I have a set of items which have a Treelist field that references media items in the Media Library. If I delete a media item which is referenced by another item, I get the "Broken Links" dialog box which gives me the option to Remove Links, Link to Another Item, or just leave the broken links.
What API/code is being called when I select Remove Links? I would like to perform this same action programmatically in the code-behind.
For context, we are allowing our advertising members to upload images and manipulate their library of images (through a custom web interface). So when someone deletes an image from their set, obviously we don't want to leave broken links to these Media Library items.
That would be the Link Database. You can utilize it before you delete the item to find referrers:
Sitecore.Globals.LinkDatabase.GetReferrers(item)
The returned ItemLink objects contain the item and field where the item you are deleting is referenced. Use the appropriate Field class to remove the reference.
Though you may think the RemoveLinks or RemoveReferences method on the LinkDatabase will do what you're looking for, it's actually just removing links/references from the Link Database itself.
EDIT:
A little Reflector work comes to a more complete solution... if you use the FieldTypeManager factory to get the field's CustomField, you can call RemoveLink(ItemLink) on the field.
Field field = item.Fields[brokenField];
CustomField field2 = FieldTypeManager.GetField(field);
item.Editing.BeginEdit();
field2.RemoveLink(itemLink);
item.Editing.EndEdit();
This is untested code, found by referencing Sitecore.Shell.Applications.Links.EditLinksForm

Categories