- 404 Error Page
- Add more default sized for images
- Auto-Resize Custom Designer Window
- Avoid Version errors with Assembly Binding
- Hook into dynamic content events
- Change CDN URLS
- Change the Title of a custom designer
- Change Widget Icons
- Change Url Regex Validation
- Delete a Forms Column from the database
- Fix: Dangerous Request.Form value Error
- Forms Input Validatation
- Get the content of a newsletter
- Get Category of an Item
- Get Filter Applied to a Widget
- Get the URL of an Item
- Get a Control Reference
- Hide items from the toolbox
- Get Last Modified Pages
- jQuery in your Masterpage
- List of Pages which a certain control type
- Modify Control Filtering
- Prefix your form tables in the database
- Programmatic Login
- Rename a Forms Database Table
- Remove the Edit Button on a widget
- Run with multiple Worker Processes and avoid errors
- Speed up Development Cache
- Store your Config in the DB
- Style Design Mode
- Setting a good ToolsFile.xml on the RadEditor
- Transform RSS XML to HTML
- Use Content Selectors in your Custom Controls
- Write Advanced Filtering Expressions
- Get Sitefinity Version Number
404 Error PageBoyan came up with a great tutorial on a 404 page, complete with video!
Add more default sized for imagesGo to Administration -> Settings -> Advanced and from there
ContentView -> Controls -> AlbumsBackend -> Views -> AlbumsBackendInsert -> Sections -> DefaultImgSizeSection -> Fields -> NewSize -> ChoicesConfig - and there are the choices you can edit, update and add new sizes.
Auto-Resize Custom Designer Window
Avoid Version errors with Assembly Binding
This is the code to bind the most commonly used assemblies
Add this to your web.config, and you shouldn't need to wait anymore for control vendors in the marketplace to recompile against the latest release.
So obviously missing here are the "newVersion" numbers. Just browse over to your bin directory and inspect the properties of the above DLLs to get the version # to paste in. So if you just updated to 126.96.36.199 then put that in as the newversion.
Hook into dynamic content events
Change CDN URLS
This will let you specify the URLs to obtain jQuery, MsAjax, etc
Change the Title of a custom designer
In the top of your SimpleView class where you define the designer class, just append this
This will replace the default "Edit" at the top of the popup designer!
Change Widget Icons
- Add class name in the backend toolbox settings
- Edit your stylesheet and add in that new class
- Define the image using a css background image (preferably a single sprite instead of a single image for every custom widget)
Change Url Regex ValidationWhen you type a title it auto-generates the content item url based on a regex value. Here's how you can change it for images (docs\etc are similar)
Administration->Settings->Advanced->Libraries->Controls->ImagesBackend->Views->ImagesBackendEdit->Sections->AdvancedSection->Fields->UrlName->Validation and scroll down to the Regular Expression field
Delete a Forms Column from the databaseAs you properly pointed out, each time a from is created, a corresponding table for this form is also created in the database. However, you cannot simply delete the column. Each control is also stored in the sf_meta_fields table as a dynamic property, so after you restart your application, Sitefinity will first check all dynamic properties, compare them to the columns in the form tables, and if a column is missing, will recreate it. This is why if you want to delete the column of the control from the database you should perform the following steps:
- Delete the widget from your form;
- Go to sf_meta_types, find the id of your form and with this id, find the corresponding dynamic property in the sf_meta_fields table.
- Then delete the property and delete the column in the form table.
Fix: Dangerous Request.Form value ErrorThis is an asp.net issue, and should be fixed in 4.5, but basically if you try and submit content in sitefinity and the content looks "dangerous" (like submitting html), then you get this error:
A potentially dangerous Request.Form value was detected from the clientSimple fix though (open your web.config):
Note: if you're using Claims Auth, httpRuntime should look more like this:
Forms Input ValidatationGreat article on how to set validation on the form input elements
Get the content of a newsletter
Now since the campaigns can be created either by writing html, created from template or building them as a page it is not just getting the text. You have to call a class called RawMessageSource which parses the message content and gives you the output html:
Get Category of an Item
Get the list of Taxa Guids
Get Filter Applied to a WidgetYou need to get an instance of the control on your page. Then you can
call MasterViewDefinition.FilterExpression. This will get the filter
that is set as a property of the control. Another option is overriding
InitializeControls method MasterView that your widget uses and there
check whether the dynamic filter expression returns results.<br />
The third option is getting the date query from the url evaluator<br /> <br /> <div class="reCodeBlock" style="border: 1px solid #7f9db9; overflow-y: auto;"> <div style="background-color: #ffffff;"><span style="margin-left: 0px ! important;"><code style="color: #000000;">var query = </code><code style="color: #006699; font-weight: bold;">this</code><code style="color: #000000;">.Manager.GetEvents();</code></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px ! important;"><code style="color: #000000;">query = </code><code style="color: #006699; font-weight: bold;">this</code><code style="color: #000000;">.EvaluateUrl(query, </code><code style="color: blue;">"Date"</code><code style="color: #000000;">, </code><code style="color: #006699; font-weight: bold;">this</code><code style="color: #000000;">.Host.DateEvaluatorPropertyName, </code><code style="color: #006699; font-weight: bold;">this</code><code style="color: #000000;">.Host.UrlEvaluationMode, </code><code style="color: #006699; font-weight: bold;">this</code><code style="color: #000000;">.Host.UrlKeyPrefix);</code></span></div> </div> <br />
and use <br /> <br />
DataProviderBase.SetExpressions to see if there will be items returned by your control.
Get the URL of an Item
Get a Control Reference
You should do the following - iterate through the Controls collection of a PageData and then use page managers .LoadControl() for each control and verify the returned result
Hide items from the toolbox
Get Last Modified Pages
jQuery in your Masterpage
This is the preferred way to do it as it'll load whatever the current embedded jQuery version is inside of sitefinity.
List of Pages which a certain control type
- Create the markup the json will be loaded into
Make sure to replace "stevemcniven" with whatever your twitter name is, and also you can change the "count" to something other than "1" :)
- Make sure the widget loads the script at the end of the page before the end body tag...it's one of the radio buttons.
- ...and this should be obvious, but please make sure you're loading jQuery somewhere so this runs :)
- Create the markup the json will be loaded into
Modify Control FilteringThis post by Boyan shows you how to change filters on your controls so they don't conflict.
Prefix your form tables in the databaseBy default sitefinity just willy-nilly creates new tables for forms named as some version of the form name itself. However most people who look at sql would prefer to have them all grouped together in sqlms.
So here's how you can set a prefix:
- ContentView->Controls->Forms Backend->Views->FormsBackendInsert->Sections->MainSection->Fields->Name
- Edit the prefix text property
Users are logged out by calling SecurityManager.DeleteAuthCookies()
Rename a Forms Database TableI've been a big supported of the idea that forms need to have a prefix, otherwise your schema will go all to hell since the default naming is "sf_form_title"...bleh. So this will retroactivly allow you to fix those.
Remove the Edit Button on a widgetThis is something that should be in there with "Granular Permissions"...however in the meantime, MVP Tim has a quick jQuery workaround!
Run with multiple Worker Processes and avoid errors
By default if Sitefinity is running in a single server scenario we use data cache for OpenAccess to minimize the queries to the database as OpenAccess caches the results.
However if your website is setup to run under multiple application pools the data cache must be disabled. Otherwise each application pool will use the OpenAccess data cache and there will be discrepancies between the cache on both pools, and you will receive exceptions such as this one.
In this case you must disable the cache by going to Administration -> Settings -> Advanced -> Data and set EnableDataCaching to false.
Speed up Development Cache
The basic concept is that you're setting IIS to compile the pages to a RAM Disk, very smart!
Store your Config in the DB
Configuration files are a "mirror" of the database. Every time you open or modify your project it gets information from its configuration files. Right before that configuration files verify that same configurations are available in the database, and only when this condition is fulfilled, information is send to your project. In other words, when your config file is opened, it connects to the database, makes sure that configurations at both places are the identical and then sends information for a change (dummy change) to your project . That's why you get a "file has changed" massage when no actual change has been done. With the release of Sitefinity 4.0 you are able to move your configuration files to the database, as shown in this blogpost. If this is done, there won't be any verification between your project and the database and you won't get warning messages.
Style Design Mode
Its as simple as knowing the css classes to target!
Setting a good ToolsFile.xml on the RadEditor
Go to Settings->Advanced->Appearance
So this is the RadEditor configuration...
Here's a good basic Editor config that wont let your editors screw with Fonts (for example)
Save this to ~/App_Data/ToolsFile.xml
** The FormatCodeBlock is for me ** :) General non-programming sites will not need it
Ok so now in the settings area, change the StandardEditorConfiguration, and MinimalEditorConfiguration to be ~/App_Data/ToolsFile.xml
Save, and done!
Transform RSS XML to HTML
- Go to Administration>Settings - click on Advanced link
- Go to Publishing and select Transform RSS XML to HTML option (see attached file)
- Save Changes
Use Content Selectors in your Custom Controls
This is a blog post by Josh Morales (SelArom), shows how you can use the built-in sitefinity page, image, etc selectors in your custom controls.
Write Advanced Filtering ExpressionsCategory
Custom fields for filtering (for number custom field)
Get Sitefinity Version Number