DNN - What control to use for images in custom module settings? - module

I am creating modules using the template created by Chris Hammond (TYVM Chris).
My modules have a few things that can be edited by the user in the settings area, one of them being an image.
I can use a TextBox and have the user type the root relative path to the image, but it is a little clunky because the user has to upload the image in the file management area of the website, get the path, then add it to the module settings. It would be a lot smoother if I could have a Image selector that would tie into the DNN files and allow the user to select an image that has been previously uploaded to DNN or add their own.
How would one accomplish this?

I suggest you to use the FilePickerUploader control of DNN.
You could see what it looks like in the Portal Settings (in Admin menu). It's used for the selection of the logo file, background image and favicon.
For example, it could be use like this:
<%# Register TagPrefix="dnn" TagName="FilePickerUploader" Src="~/controls/filepickeruploader.ascx" %>
<dnn:FilePickerUploader ID="ctlFavIcon" runat="server" Required="True" FileFilter="ico" />
Required and FileFilter attributes are optionnal and I think it provides other options.

Just use a DNNEditor webcontrol
<%# Register TagPrefix="dnn" Assembly="DotNetNuke.Web" Namespace="DotNetNuke.Web.UI.WebControls" %>
<dnn:DnnEditor ToolsFile="xmfile.xml"/>
Via this control you can use the default image selector. In first place you will see a lot of selectors in the toolbar, but you can change this via a xml file and add that xml file to the property ToolsFile
Just let me know if you need more help.

Related

Magento 2.4: How to hide the Upload button in magento 2 admin?

We have an image uploader field in Magento 2 admin. When a customer uploads any document in the frontend, the file will be shown in uploader field section. Now what I need is that I want to hide the Upload button in admin and have to restrict admins to upload the attachment from admin portal.
I have tried visible=false but its hide the entire section.
Please help
Is it core Magento or Your custom uploader? Is this menu build in xml? Is it uicomponent? Seems like You want to conditionally disable element. Maybe this would be helpful:
https://karnowka.com/posts/magento2-conditional-layout-directives/
It all depends how You build the buttons. Every xml has xsd schema, that means each one has different possibilities but only few allows to conditionally hide element.
Maybe You can use:
<item name="formElement" xsi:type="string">hidden</item>
or disable element in xml.
Anyway if it's adminhtml I would start looking at xmls.

How do I create a Robots.txt editor in Sitefinity mvc?

I want to create an editor for the Robots.txt file in Sitefinity. I want to give the user ability to edit this. How do I do this? I am using the latest version of Sitefinity and MVC. Any examples or related articles, etc. will be useful.
If the user has access to Administration > File Manager, then he can go there, download the file, edit it and upload it again. That's the easiest option and does not require custom code.
If that's not an option, then you can create an MVC widget which reads the file and displays it in a textarea for instance.
User can then make changes and submit them to the controller which will save them to the file.
Then you can place this widget on a custom backend page.

Sensenet: Pagination on Document Library

It is possible to define pagination on document library?
I have a document library with more that 10000 documents... when I open the library occurs an timeout.
Actually SenseNet already does this! They just don't deliver it in the standard list control. If you open up the PRC and navigate to /Root/IMS/BuiltIn/Portal you'll see a list control with paging. The code can be found at /Root/Global/renderers/UserExploreGrid.ascx as User Control portlet. You can copy the code and change it to meet your needs.
Our company prefers to create User Control portlets and use Datatables with calls to the SenseNet OData API using skip and top to deliver pages.
Finally, given that SenseNet Content is stored as a tree structure (in SQL!), you can move the Content after creation so that data is organized hierarchically. A common solution is to take the first letter of the DisplayName and create a sub-folder from that letter, thereby reducing the number of items at a single node.
Here's what the paging looks like:
The short answer is no. Right now there isn't a built in functionality for that.
The long answer is that you can make a pagination yourself. One of the core member of sensenet made a grid where you can use pagination. It won't work with the current free to use releases because they lack the js files she used. But the idea behind it, is using a custom view. Which you can achieve by adding a system folder named Views under a the Document library and adding your custom view there.
You can use this grid for Explore, just follow these steps:
Go to the Explore action page, and switch editor mode on the PRC.
Place a ClientContext portlet (this can find under the Portlets->Application section in the portlet picker dialog) to the Wide column. Set portlet (client context porlet) properties, Apparance to None. It is a technical portlet, which allow get the CurrentContext in javascript. This is a very important element to work with this grid. The Grid use the client context.
Place a UserControlPortlet (In the portlet picker, Portlets->Application section) to the Wide Column.
Set portlet properties:
4.1. Portlet title: <%$ Resources: PortletTitles, Items%>
4.2. User Control path: /Root/Global/renderers/UserExploreGrid.ascx
Checkin Page modification on the PRC.
Enjoy your pageable explore portlet.
Keep in mind that this grid is specifically designed for users, so they will miss actions in the top menu. These must be handwritten. Then I suggest you copy the UserControl ( /Root/Global/renderers/UserExploreGrid.ascx)
and then put the action list on it . You can read more info about action list here: http://wiki.sensenet.com/ActionList
Br,
maros

Image slider link to internal or external page on Sitefinity

(Sitefinity 6.x)
I am trying to create an image slider where each image in the page links to an internal or external page. I created a separate library for all the images that I want to show on the slider then using custom MVC widget I display the images in a slider.The problem that I have is there is no place in the image where I can link the image to open an existing internal page or external website.
Is there a way to add a properties to the original Image properties? so that users can select a page (using some sort of page selector just like in the navigation widget) or type in external page to link. If that is not possible, could you give me some ideas how to implement this?
I've been creating image rotators using Module Builder in Sitefinity. What you could do is go to Administration -> Module Builder -> Create a Module, call it Image Slider, call the content type Slide. Add a couple fields, for the first call it Image and select Media for the type, this will use an image selector for the interface, then add another field called Link and use Short text for the type, this will hold the url. Unfortunately, Sitefinity doesn't include a Page Selector control as an available field yet so a text field will have to do. Save and activate your module, it will show up under Content -> Types of Content. Go ahead and add a few slides. Sitefinity has created a couple of widgets when you created the module, so if you edit a page, you'll see them under the "Content" widget section, probably at the bottom. Drag it on the page and set it to use the list template. Now open up the Sitefinity Explorer window in their Thunder Visual Studio plugin, under Common Widget Templates, you'll see an Image Slider folder, you'll want to edit the list template since you'll be outputing all the slides into some carousel markup or something. From here you can use the default Sitefinity image control and bind the link to a hyperlink that wraps the image control, this will link each image to whatever is in that field.
Hope that helps.

Using FileUpload in DNN Setting.ascx possible?

first time asking a question here.
I'm making a DNN module and in the Setting.ascx I'm trying to add any form of FileUpload in there. I'm successful at adding ASP's FileUpload as well as Telerik's RadUpload, but when I click a button I added to save and examine the uploaded the file it's empty and no longer holding any data. I thought I was coding it wrong at first, but after adding it into the View.ascx instead it works perfectly. Of course that's not where I want it to be.
I believe the problem might be how the Setting.ascx works in DNN. I believe it's using a form of AJAX to display it so that might be interfering. Hard to say though. While I'm at it can anyone confirm that Setting.ascx is using AJAX and that button clicks cause asynchronous postbacks? Thanks.
You're right with your thought that the form uses AJAX (formerly via UpdatePanel, now via RadAjaxPanel in DNN 6.x), and that's what's interfering with the upload. In most scenarios, you'd just switch to a regular postback by calling ScriptManager.RegisterPostBackControl, but in the settings case, you don't have a direct reference to the LinkButton that saves the settings.
You'll probably need to add your own button to the form to do the upload after the user has selected the file. DNN's own UrlControl uses a system like that, where there's an Upload button next to the Browse button. DNN also has a newer DnnFilePicker control, which might also encapsulate what you want. You'll just need to add an # Register directive to use those. For example:
<%# Reference tagPrefix="dnn" tagName="UrlControl" Src="~/controls/URLControl.ascx" %>
<%# Reference tagPrefix="dnn" Assembly="DotNetNuke.Web" Namespace="DotNetNuke.Web.UI.WebControls" %>
<dnn:UrlControl runat="server" ID="FileUpload"
ShowLog="false"
ShowNewWindow="false"
ShowTrack="false"
ShowImages="false"
ShowNone="false"
ShowTabs="false"
ShowUrls="false"
ShowUsers="false"
ShowFiles="false"
ShowUpLoad="true" />
<dnn:DnnFilePicker runat="server" ID="FilePicker"
FileFilter="jpg,png,gif" />
Man, just don't put a updatepanel outside your ascx control
If you need to use updatepanel, put it inside the ascx. That will resolve your problem!
I was able to solve this problem by doing the following:
Create my own submit button as opposed to relying on the "Save" button built into the page
Adding the following to my LoadSettings() method:
ScriptManager.GetCurrent(this.Page).RegisterPostBackControl(cmdUpload);
Where cmdUpload is the ID of my submit button.
You will need to add a reference to System.Web and System.Web.Extensions for this to compile.