With orchard CMS, Is it possible to add a widget to a zone in the admin? - widget

Is it possible to add a widget to a zone in the admin? So you see the widget while administering. (As the admin theme uses zones too)
If not is it possible to do something similar?

Not currently, not exactly. If you look at the TheTree module, it does add UI elements to the admin, but not exactly a widget.

Related

How can I hide element html depends role in angular

I have 4 kind of profiles (role)
adminstrator
Super Admin
Admin
User
every profile has it's own pages of creation or displaying but with little difference, I guess it's waste of time when I create component just to add one fields, so is there any solution how to hide/show element html depends role ?
You can make an enum of roles and use it in your html via ngIf or NgTemplateOutlet.

How to add HTML attributes in generated widget from Victoire

I would like to add an "onclick" attribute in buttons widget generated by Victoire CMS, in order to track click events by GoogleAnalytics. How can I do it ?
Cheers
So I suppose you're talking about a Widget Button here.
It's not planned to allow users to add as many attribute as they want on this widget. However you have multiple solutions.
1 - Use a Render Widget (recommended)
Replace your Button Widget with a Render Widget and call a route from on of your application Controller. You can add as many parameters as you want : in your case it can be useful to change the Google Analytics event name depending on the button you create.
2 - Themes (quickest)
Each Widget view can be overridden by using a custom Theme. For example, here you can create the file app/Resources/VictoireWidgetButtonBundle/views/showGoogleAnalytics.html.twig.
Copy the code from the original view vendor/victoire/button-widget/Victoire/Widget/ButtonBundle/Resources/views/show.html.twig and change it as you want.
Then you just have to edit your Widget in Style mode and select the theme you just added. If your theme doesn't appear here, clear your cache or check that the path is corresponding to the path described above.
However, this method add a new available Theme for all your buttons and it can cause errors if your client try to apply this Theme in another Button. That's why we recommend the first solution.
3 - Use an HTML Widget (quick & dirty)
HTML Widget allow you to add your custom HTML code.
U can use this:
<button onclick="myFunction()">Click me</button>
myFunction() is a function in javascript which will be done when you click on a button.
Every attribute can be added by setAttribute("attribute", "value");

Reusable HTML Blocks in Sitecore

I'm looking for a way to create a reusable HTML widget for a website run on Sitecore 8. My original idea was to create a data template that basically consisted of a single Rich Textbox. The idea is that you could drop any number of instances of these widgets on a placeholder and it would render out the HTML from each instance of the widget on the page and in the correct placeholder.
Example:
A content item called /products/my-product is based off of "Product" data template
It consists of some fields on the Product template (maybe product name, price)
I'd like the ability for the content editor to quickly drop one or more instances of the HTML widget on the page (say, in the right rail or in a different placeholder on the sublayout. I know I could just throw a "notes" field on the product template, but I'd like to make it more dynamic so that they can add several instances of this HTML widget and place them anywhere they desire.
I quickly realized that because we need the ability for multiple instances of this widget, a data template was not enough because each instance of the widget would needs its own data to populate on the front. Thus, my idea was to allow the content editor to add HTML widgets as a child of the current item (so each item would have its own instance data). I don't think this will work because I don't know of a way to have these children tell the parent page which placeholder to put them in, so laying them out is a problem.
I also thought about somehow setting the placeholder name as a parameter or field on the data template for the HTML widget, but I couldn't figure out how to get Sitecore to dynamically add them to a placeholder when it glues everything together.
Is there a way to achieve what I'm trying to do? Seems like a reusable HTML (or other kind of widget, for that matter) would be a fairly common need. I feel like there's an easy Sitecore way to handle this that I'm missing and overcomplicating the solution.
From what I understand, you're looking for Datasource field of a component.
Basically you:
Create a data template which contains fields necessary for your component
Create a set of items using that templates
Allow authors to select one of them as the Datasource for your component.
It's built in Sitecore functionality.
Check blog post http://firebreaksice.com/using-the-datasource-field-with-sitecore-sublayouts/ or google for Sitecore datasource.
Other links:
http://www.nonlinearcreations.com/Digital/how-we-think/articles/2014/03/4-patterns-Sitecore-component-development.aspx
http://www.nonlinearcreations.com/Digital/how-we-think/articles/2015/04/Sitecore-templates.aspx
EDIT:
Read about Datasource Location field (defining the repository of datasources location) here: http://www.sitecore.net/learn/blogs/technical-blogs/getting-to-know-sitecore/posts/2011/01/handling-presentation-component-settings.aspx
Read about Datasources and MVC here: http://jockstothecore.com/sitecore-mvc-item-maze/

html css menu visibility hide by permissions

I would like use an html/css menu and hide menu items based on users permissions/rights. What would be the best way to handle this? Can it be done just using CSS/HTML or using scripting like Javascript.
The permissions are through "allow roles" subfolders with web.config authorizations. So users cannot go to the wrong page but I want to hide the choices they can't actually access.
I am using VB.net code behind FYI.
You can't do this in static CSS/HTML, but you could print different CSS statements for each role if you dynamically generate it.
Or you could assign class 'admin' to certain items, set to display:none in CSS then use jQuery to show them:
if(userIsAdmin)
{
$('.admin').show();
}
However, I prefer to do this server-side if possible and only print certain items for certain users because, as Yoda said, anyone can see the source if you do it client side.

How to set focus on tab in tabcontrol in URL

I am trying to call a page in my customers webapplication (Exact Synergy Enterprise)
This is the link: http://someserveridontdisclose/Synergy/docs/CSCANEduCourseCard.aspx?ProjectNr=ACPGINTV
Within this page is an Ajax TabContainer with several TabPanels. One of them is called 'Doelgroepen'
I dont have the source for this application, as i am not the developer of it. We only develop custom extentions to it.
Here's the question: Is it possible to focus on one of the tabs USING ONLY AN URL? If so How?
Thank you very much for your thoughts about this.
try to set with javascript. you'll have to write your own js to get index number you want from url, then set like this
$find('<%=TabContainer1.ClientID%>').set_activeTabIndex(2);
http://forums.asp.net/t/1127834.aspx
http://www.aspforums.net/Threads/420684/ASPNet-AJAX-TabContainer-Set-Active-Tab-Client-side-using-JavaScript/
If you do not have access to the code and if this is not part of the requirement / design specification for the application you are using (ie: what you asked the developer to do), then the answer is No.
The control does not have "native" support for URL tab selection. There needs to be specific code in the application in order to handle this.
It is however very easy to implement, if you absolutely need it, it shouldn't take much time (about 15-30 lines of code, depending on how many tabs/urls combination you need).
You can find a running sample of the AjaxControlToolkit Tabs control at the following link (the available functionnalities are described in there):
http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/Tabs/Tabs.aspx
If the TAB has an ID you could make it visible by adding '#tabid' to the URL.