Posts

Showing posts from 2017

Umbraco 7 Get Media images by ID when using the Multi Media Picker to display a Gallery

Umbraco 7 Get Media images by ID when using the Multi Media Picker This is usefull when creating a gallery of images. 1) In your Doctype add the Multiple Media Picker 2) Umbraco 7 Razor code snippet partial: @inherits Umbraco.Web.Mvc.UmbracoTemplatePage @helper RemoveExtensions(string stringIn) {  var thisTitle = stringIn;                                         thisTitle = thisTitle.Replace(".jpg", "");                                         thisTitle = thisTitle.Replace(".png", "");                                         thisTitle = thisTitle.Replace(".jpeg", "");                                         thisTitle = thisTitle.Replace(".gif", "");                                         thisTitle = thisTitle.Replace(".bmp", "");                                         thisTitle = thisTitle.Replace("-", " ");                                        

Convert an SDF file to a MDF - File useful for Umbraco 7

How to convert a SDF Compact Database file to a full blown SQL Server MDF file. PART ONE (change the SDF file to MDF file): a) Install SQL Server Compact Toolbox runtime b) Start SQL Server Compact Toolbox runtime c) Select Add and Browse to the SDF file that you want to convert d) Select Sctipt Database Scheme and Data (this will produce a script) PART TWO (import the database in to SQL Server Management Studio) a) In SQL Server Management Studio create a Blank Database b) Right Click on the new database and select New Query c) Paste in the script and press execute: this will create all the Umbraco tables. Now you just need to update your umbraco config file to point to the new database.

Umbraco 7 Redirect to Another Node - Redirect to Parent Node

Umbraco 7 Redirect to Another Node - Redirect to Parent Node Response.Redirect(@CurrentPage.Parent().Url);

Umbraco 7 Tag and Sorting Tags in to Alphabetical Order Using a Dictionary

Umbraco 7 Tag and Sorting Tags in to Alphabetical Order Using a Dictionary: <ul> @{     Dictionary<string, int> tagsList =             new Dictionary<string, int>(); }  @foreach (var c in CurrentPage.Children())     {         if(c.HasValue("tags"))         {                    foreach (var item in c.GetPropertyValue<string[]>("tags"))            {                 if (!tagsList.ContainsKey(item))                 {                               tagsList.Add("" + item, 1);                     <!--<p>@item</p>-->                 }            }                   }         }     @{      var ordered = tagsList.OrderBy(x => x.Key);                                foreach(var i in ordered)                 {                  <li class="filterLink"><a href="@i.Key">@i.Key</a></li>                 }                 <!--<li class="filterLink

Umbraco 7 Convert Line Breaks in Text Area when Outputing brs

 @Html.Raw(@umbraco.library.ReplaceLineBreaks(@CurrentPage.buildAddress))

Umbraco 7 Year Now Razor Snippet

How to display the current year in Razor and in Umbraco 7  @DateTime.Now.Year For example: <p>Copyright &copy; @DateTime.Now.Year </p> I use this on a lot of my umbraco websites for keeping the copyright up to date.  You can see an example of this on the footer of my most recent Umbraco website design at: http://www.markdevelopment.co.uk/portfolio/abercromby-heating-and-plumbing-services/

Umbraco 7 HTML Site Map Partial View

@inherits Umbraco.Web.Mvc.UmbracoTemplatePage @{ var home = CurrentPage.Site(); } @if (home.Children.Any()) {     @* Get the first page in the children *@     var naviLevel = home.Children.First().Level;     var listChildPages = "false";     @* Add in level for a CSS hook *@     <ul style="margin-top:0px;paddin:0px;font-size:16px;">                 @* For each child page under the home node *@         <li><a href="/" title="@CurrentPage._siteTitle">Home</a></li>         @foreach (var childPage in home.Children.Where("Visible"))         {             if (childPage.Children.Any() && listChildPages =="true"  && childPage.id != 1110)             {                                 <li style="margin-bottom:5px;">                         @if(@childPage.HasValue("navigationName"))                         {                             <a href=

Umbraco 7 Metadata, Keywords, Description and Title

@{            var SEOTitle = "";         var SEODescription = "";         var SEOKeywords = "";      }      @if(CurrentPage.seoTitle != null && CurrentPage.seoTitle != "")      {         SEOTitle = CurrentPage.seoTitle;      }      else      {         SEOTitle = @CurrentPage.Url.Replace("/"," | ") + @CurrentPage._siteTitle;         SEOTitle = SEOTitle.Substring(2, SEOTitle.Length-2);      }          @if(CurrentPage.seoDescription != null && CurrentPage.seoDesctiption != "")      {         SEODescription = CurrentPage.seoDescription;      }      else      {         SEODescription = "This page is about" + @CurrentPage.Url.Replace("/"," ") + @CurrentPage._siteTitle;      }      @if(CurrentPage.seoKeywords != null && CurrentPage.seoKeywords != "")      {         SEOKeywords = CurrentPage.seoKeywords;      }      else      {