How to identify in code that webpart is used full-width in SPFx - sharepoint-online

Currently i'm able to create webpart in SharePoint that is allowed to use in full-width mode(manifest:"supportsFullBleed": true). But i need to change some styles accordingly. Is there any way how to identify that webpart is used full-width in code?
SPFx used: 1.15.2
I tried check of width of element, it works in some cases, but when full-width webpart is used in for example mobile than width its not reliable.

The best shot I've seen regarding this may be the "formFactor" context property (it's hidden/not available with type definitions, but actually it exists):
https://learn.microsoft.com/en-us/javascript/api/sp-webpart-base/basewebpartcontext?view=sp-typescript-latest##microsoft-sp-webpart-base-basewebpartcontext-formfactor-member

Related

Kentico Widgets :: Matching fields with HTML structure of Web Part

I really hope I'm making sense with this one.
I'm trying to create a widget from a custom webpart that I created. It's nothing special at all as you can see:
<h3>Header</h3>
<p>Intro Copy</p>
<ul>
<li>List item one</li>
<li>List item two</li>
<li>List item three</li>
</ul>
I now want to be able to create a widget from this and create new fields that will be used to populate the above DOM. What do I need to do in order or do this.
In an example I saw for the demo site, they populated the bg image with:
style="background-image: url('{% ResolveUrl(PathToImage) %}');"
That was however done on the front facing part of the CMS and I'm trying to do it within the solution.
Any thoughts?
It's all in your layout or code behind. Your layout can have that code (but in ASCX format) and it will work just fine. OR you can add literal controls to the page based on the fields and what the user has entered.
Doing it in your layout is more restrictive and specific to that one application but allows you to use multiple new webpart layouts. Using the code approach allows you to be more dynamic but doesn't allow you to use the built-in layouts of the webpart/widget.
I would just use the Transformable Web Part in the Marketplace...it does exactly what you want it to do. Create a custom web part, and you use a Transformation to style the Web Part Properties into the DOM elements.
https://devnet.kentico.com/marketplace/web-parts/transformable-web-part
Reason why i built it!
I've done something similar in the past, using what I call generic web parts. I wrote a blog on it last year - it might help out with what I think you're trying to achieve:
http://www.mattnield.co.uk/Posts/Show/generic_web_parts_for_rapid_development
Why are you choosing to go with Widgets? If you want to access any field inside the transformation within the web part it's feasible by the same way as you define in inbuilt web parts.
If you want to perform any function like onload etc. then you need to use kentico API to access any data.
If you provide more insight on what is required, I can help further

How to customize blog portlet in liferay

I am new to liferay and using liferay-ce-portal-7.0-ga3 i have placed a blog and able to write contents in it. i want to change the blog portlet design by adding thumbnail preview to it . My current view is it has either title,abstract and full content view. How could i customize to get blog view
You can customize Liferay's appearance through Application Display Templates (ADT). Unfortunately there's no sample for the OOTB appearances, but when you go to your site's (or the global site's) Configuration area, you can find/edit/create ADTs there. Depending on the markup and CSS, as well as your typical image size etc., the actual ADT you write would be different, thus impossible to include anything here.
The editor however, has some autocomplete and some predefined entries/fields, that should give you a starting point. E.g. when you just open a blank editor and hit the "Blog Entries" field, you'll end up with
<#-- Application display templates can be used to modify
the look of a specific application. Please use the
left panel to quickly add commonly used variables.
Autocomplete is also available and can be invoked
by typing "${". -->
<#if entries?has_content>
<#list entries as curBlogEntry>
${curBlogEntry.title}
</#list>
</#if>
You'll find what you can do with BlogsEntry in it's javadoc, make sure to follow the BlogsEntryModel superclass link as well to see more.
I'll have to leave the exercise to generate proper markup and styling to you though.

Creating tooltips for each field in Sharepoint form

I want to create tool tips for each part in a form which employees have to fill in a share point web page. When users move the mouse cursor on each field (Title, description, department etc.) the related tip will be automatically became visible as a simple pop-up (tool tip) and summarize what they should write there. and when the mouse cursor is not on one of these fields there is no tool tip.
How can I design such a system via share point designer? I am not able use any add ons. I can't upload any additional things to the server. I have to make page based design.
I would be glad if you kindly help me.
Have you considered using field description?
This is SharePoint's default way of adding additional information to fields.
I couldn't find the ToolTip control in my SharePoint Designer 2007 Toolbox, so I looked on W3Schools.com for a standard HTML option and found that you can use the <ABBR> tag.
See http://www.w3schools.com/tags/tag_abbr.asp for the reference, but here's an example of a tooltip implemented on a SharePoint field title in a display form:
<td valign="top" class="ms-formlabel" style="width: 50px">
<H3 class="ms-standardheader">
<nobr><abbr title="The actual number of man-days effort expended.">Man-days (Actual)</abbr></nobr>
</H3>
</td>
Open up the aspx page for the form in SharePoint designer. Then you can use SharePoint designer just like Visual Studio to see the code. Try adding the "tooltip" attribute to the field controls within the form. There is a small possibility these controls will actually be written using XSLT instead of ASP, so be prepared to do some studying.
By default the display name of the site column becomes the tool tip for that field.

Dynamic SharePoint web part width and height

I am trying to dynamically adjust the width and height of a web part in a SharePoint web part page so that it fills up the entire available space. It appears that there is no way to choose a percentage for width and height from the web part property editor window in SharePoint. Also, trying to dynamically set it on the web part instance through code results in SharePoint throwing an exception to the effect that proportional dimensions are not supported.
Is there any way to do this using, for example, Javascript? I've seen similar things done using jQuery, but not exactly what I'm looking for (and I'm not familiar enough with jQuery to come up with something on my own).
There is a web part available that does this here. You can also see a solution on TechNet communities from "potta vijay kumar" (where I found that web part too):
function calcHeight()
{
//find the height of the internal page
var the_height=
document.getElementById('contentpage').contentWindow.
document.body.scrollHeight;
//change the height of the iframe
document.getElementById('contentpage').height=
the_height;
}
contentpage is the ID of the iframe.
A jQuery solution is available from EndUserSharePoint.
Here's what I did:
I had an iFrame inside the middle webpart, where I will be loading webpages based on the left web part menu. So I took the <td> element where both the webparts are placed (its a <td> element with class set as ms-bodyareaframe)
var head=$('td.ms-bodyareaframe');
$("#myFrame").height(head.position.height()).attr('src',unescape(loc));
$("#myFrame").parent().height(head.height()-50);
This will perfectly re-size the webpart where the iframe resides.
Note: this may not work in all cases

Customize SharePoint:FormFields to a specific height

I'm customizing a NewForm.aspx page and I've created a few new SharePoint:FormFields in the form of textboxes. I'm looking to customize the height of these boxes on a case-by-case basis, but I can't figure it out.
I've looked into DisplaySize, but that only controls the width of a specific textboxe, and I've seen adding in:
<style>
.ms-long{width:100px;}
</style>
but that changes every SharePoint:FormField size, not just one.
Find the element in the complete html output, and use the id rather than the class as the css selector. If you can't find a suitable selector or you need to use selectors not supported in ie, you can use javascript/jquery to find and modify individual controls.
If you are customizing the NewForm.aspx, and you want to customize the look of the controls, you should also customize the CSS by using your own .css file. That may or may not include a customized master page.
I take it your a user of SharePoint Designer to be editing NewForm.aspx. Personally the route I would go down is to design a custom text box field and give it the desired size that way. Might not be what you want, but it's one way to do it.

Resources