Søg
Alle nyheder
  Alle nyheder (RSS-feed)
Projekt Sund Mand
20. november 2017

Projekt Sund Mand

Evaluering af projekt Sund Mand

Ladywalk Tarm 2018
24. august 2017

Ladywalk Tarm 2018

mandag den 28. maj 2018

Søndagsaktiviteter 2017
8. september 2016

Søndagsaktiviteter 2017

Her kan du hente folderen over søndagsaktiviteter 2017

Film fra Ladywalk 2016 i Tarm
8. september 2016

Film fra Ladywalk 2016 i Tarm

Se den glade stemningsvideo her

Exception in template (Designs/institution-skabelon/Paragraph/aaben_skole_products.cshtml): System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.fdfbbfcffdbb.Execute()
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context)
   at RazorEngine.Templating.TemplateService.Run(ITemplate template, DynamicViewBag viewBag)
   at RazorEngine.Templating.TemplateService.Parse(String razorTemplate, Object model, DynamicViewBag viewBag, String cacheName)
   at RazorEngine.Razor.Parse[T](String razorTemplate, T model, String cacheName)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()
@inherits RazorTemplateBase<RazorTemplateModel<Template>> @using System; @using System.Web; @using Dynamicweb; @using Dynamicweb.Data; @using Dynamicweb.Rendering; @using Dynamicweb.Content.Items; @using System.Data; @using System.Collections; @using System.Text.RegularExpressions @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> @using System.Web @using System.Linq @functions { string GetImageUrl(string url, int width = 200, int height = 200) { if (string.IsNullOrWhiteSpace(url)) { url = string.Format("http://placehold.it/{0}x{1}", width, height); } if (!url.StartsWith("http://")) { url = string.Format("/Admin/Public/GetImage.ashx?Image={0}&width={1}&height={2}", url, width, height); } return url; } string GetAbsoluteUrl(string url) { var request = HttpContext.Current.Request; return request.Url.Scheme + "://" + request.Url.Host + url; } string GetQueryParameter(string name) { return HttpContext.Current.Request[name]; } string BuildUrl(dynamic parameters, bool clear = false) { return BuildUrl(HttpContext.Current.Request.Url.PathAndQuery, parameters, clear); } string BuildUrl(string url, dynamic parameters, bool clear = false) { var dict = new Dictionary<string, object>(); if (parameters != null) { var type = parameters.GetType(); var properties = type.GetProperties(); foreach (var property in properties) { dict.Add(property.Name, property.GetValue(parameters)); } } return BuildUrl(url, dict, clear); } string BuildUrl(string url, Dictionary<string, object> parameters, bool clear = false) { var query = HttpUtility.ParseQueryString(""); var index = url.IndexOf('?'); if (index > -1) { if (!clear) { query = HttpUtility.ParseQueryString(url.Substring(index)); } url = url.Substring(0, index); } if (parameters != null) { foreach (var e in parameters) { query.Remove(e.Key); query.Add(e.Key, e.Value == null ? "" : e.Value.ToString()); } } if (query.Count > 0) { query.Remove("debug"); query.Remove("dbstat"); query.Remove("parse"); query.Remove("purge"); return string.Format("{0}?{1}", url, query); } else { return url; } } public static string RemoveQueryStringByKey(string url, string key) { var uri = new Uri(url); // this gets all the query string key value pairs as a collection var newQueryString = HttpUtility.ParseQueryString(uri.Query); // this removes the key if exists newQueryString.Remove(key); // this gets the page path from root without QueryString string pagePathWithoutQueryString = uri.GetLeftPart(UriPartial.Path); return newQueryString.Count > 0 ? String.Format("{0}?{1}", pagePathWithoutQueryString, newQueryString) : pagePathWithoutQueryString; } } @using System.Text.RegularExpressions; @functions { string GetExcerpt(string text, int length, string dots = " …") { var excerpt = Regex.Replace(System.Net.WebUtility.HtmlDecode(text), "<[^>]*>", ""); if (excerpt.Length > length) { excerpt = excerpt.Remove(length); excerpt = Regex.Replace(excerpt, @"\s[^\s]+$", ""); excerpt += dots; } return excerpt; } } @functions { string StripTags(string content) { return Regex.Replace(content, "<[^>]*>", ""); } string XmlEncode(object value) { return value != null ? XmlEncode(value.ToString()) : null; } string XmlEncode(string value) { return System.Net.WebUtility.HtmlEncode(System.Net.WebUtility.HtmlDecode(value)); } string XmlElement(string elementName, object content) { var s = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", content); if (string.IsNullOrEmpty(s)) { return "<" + elementName + "/>"; } else { // Prevent Html Agility Pack from messing up the markup return "<" + elementName + ">" + s + "<" + "/" + elementName + ">"; } } } @using Dynamicweb.Content.Items; @functions { IEnumerable<Item> GetItemsByIds(string itemType, string idList) { var ids = idList.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList<string>(); return GetItemsByIds(itemType, ids); } IEnumerable<Item> GetItemsByIds(string itemType, List<string> ids) { try { var repo = new Dynamicweb.Content.Items.Queries.Repository(itemType); var items = repo.SelectByIds(ids).OrderBy(i => ids.IndexOf(i.Id)); return items; } catch { } return null; } } @helper DUMP(object value, string heading = null) { // https://github.com/dynamicweb/razor/wiki/Using-Json.Net-to-inspect-values <pre class="dw-dump">@if (heading != null) {<text>@heading</text> } @Newtonsoft.Json.JsonConvert.SerializeObject(value, new Newtonsoft.Json.JsonSerializerSettings { ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore, MissingMemberHandling = Newtonsoft.Json.MissingMemberHandling.Ignore, Error = (serializer,err) => err.ErrorContext.Handled = true, Formatting = Newtonsoft.Json.Formatting.Indented }) </pre> } @helper Paging(int all_results_count, int result_per_page, string goto_url = "") { //check if goto URL is set, if not, use current URL if (String.IsNullOrEmpty(goto_url)) { goto_url = GetAbsoluteUrl(HttpContext.Current.Request.RawUrl); goto_url = RemoveQueryStringByKey(goto_url, "page"); } //set the query base, so we can easily manipulate with URL for paging after string querybase = ""; if (goto_url.Contains("?")) { querybase = goto_url + "&page="; } else { querybase = goto_url + "?page="; } //What page are we on? int currentPage = 1; if (!String.IsNullOrEmpty(HttpContext.Current.Request["page"])) { currentPage = Convert.ToInt32(HttpContext.Current.Request["page"]); } //How many pages do we have? double numberOfPages_tmp = (double)all_results_count / (double)result_per_page; double numberOfPages = Math.Ceiling(numberOfPages_tmp); //Determine start and end and how many to display int vis_antal = 4; double start = currentPage - vis_antal; double slut = currentPage + vis_antal; if ((currentPage - start) < vis_antal + 1) { slut = slut + (vis_antal - (currentPage - start)) + 1; } if ((slut - currentPage) < vis_antal) { start = start - (vis_antal - (slut - currentPage)); } if (start < 1) { start = 1; } if (slut > numberOfPages) { slut = numberOfPages; } if (currentPage > 5 && numberOfPages < 8) { start = 2; } int prevPage = currentPage - 1; int nextPage = currentPage + 1; //if we have any pages to display, do it string query = ""; if (numberOfPages > 1) { <ul class="nav nav--paging"> @if (currentPage > 1) { query = querybase + prevPage; <li class="nav--paging-item"> <a href='@query' class="icon">&#xf100;</a> </li> } @if (currentPage > vis_antal + 1) { query = querybase + "1"; <li class="nav--paging-item hidden-xs"><a href='@query'>1</a></li> } @if (currentPage > vis_antal + 2) { if (start == 3) { query = querybase + "2"; <li class="nav--paging-item hidden-xs"><a href='javascript:void(0);'>2</a></li> } else if (start == 2) { } else { <li class="nav--paging-item hidden-xs">...</li> } } @for (double page_i = start; page_i <= slut; page_i++) { if (page_i == currentPage) { <li class="nav--paging-item nav--search-paging-item--active hidden-xs">@page_i</li> } else { query = querybase + page_i; <li class="nav--paging-item hidden-xs"><a href='@query' title="">@page_i</a></li> } } @if (slut + 1 < numberOfPages) { if (slut == numberOfPages - 2) { slut++; query = querybase + slut; <li class="nav--paging-item hidden-xs"><a href='@query'>@slut</a></li> } else { <li class="nav--paging-item hidden-xs">...</li> } } @if (slut < numberOfPages) { query = querybase + numberOfPages; <li class="nav--paging-item hidden-xs"><a href='@query'>@numberOfPages</a></li> } @if (currentPage < numberOfPages) { query = querybase + nextPage; <li class="nav--paging-item"> <a href="@query" class="icon">&#xf101;</a> </li> } </ul> } } <div class="aabenskole--product-container"> @{ //get item info for page Item item_page_info = Dynamicweb.Content.Items.ItemManager.Storage.GetById("Template___ben_Skole_Listeside", Pageview.Item.Id); //build query where for paging string queryWhereExtend = ""; //Query possibilities from search string query_term = GetQueryParameter("term"); if (!String.IsNullOrEmpty(query_term)) { query_term = query_term.ToLower(); queryWhereExtend = queryWhereExtend + " AND (a.Tekst LIKE '%'+@SQL_TERM+'%' OR a.Overskrift LIKE '%'+@SQL_TERM+'%')"; } string query_topic = GetQueryParameter("Emne"); string current_topic = ""; if (item_page_info["Emne"] != null && !string.IsNullOrEmpty(item_page_info["Emne"].ToString())) { query_topic = item_page_info["Emne"].ToString(); } if (!String.IsNullOrEmpty(query_topic)) { queryWhereExtend = queryWhereExtend + " AND a.Emne LIKE '%'+@SQL_TOPIC+'%'"; } string query_subject = GetQueryParameter("Fag"); if (!String.IsNullOrEmpty(query_subject)) { queryWhereExtend = queryWhereExtend + " AND a.Fag LIKE '%'+@SQL_SUBJECT+'%'"; } string query_ages = GetQueryParameter("Alderstrin"); if (!String.IsNullOrEmpty(query_ages)) { queryWhereExtend = queryWhereExtend + " AND a.Alderstrin LIKE '%'+@SQL_AGES+'%'"; } string query_period = GetQueryParameter("Periode"); if (!String.IsNullOrEmpty(query_period)) { queryWhereExtend = queryWhereExtend + " AND a.Periode LIKE '%'+@SQL_PERIOD+'%'"; } //What page are we on? int current_page = 1; if (!String.IsNullOrEmpty(HttpContext.Current.Request["page"])) { current_page = Convert.ToInt32(HttpContext.Current.Request["page"]); } //Paging vars int sql_offset_start = ((current_page * 8) - 8) + 1; int sql_offset_end = current_page * 8; int all_results_count = 0; using (IDbConnection connection = Database.CreateConnection()) { //Count totalpages for paging IDbCommand command_count = connection.CreateCommand(); command_count.CommandText = @"SELECT COUNT(a.Id) FROM ItemType_Itemliste___ben_Skole_Produkt AS a INNER JOIN ItemListRelation AS b ON a.Id = b.ItemListRelationItemId WHERE b.ItemListRelationItemListId=1" + queryWhereExtend; Database.AddStringParam(command_count, "@SQL_TERM", query_term); Database.AddStringParam(command_count, "@SQL_TOPIC", query_topic); Database.AddStringParam(command_count, "@SQL_SUBJECT", query_subject); Database.AddStringParam(command_count, "@SQL_AGES", query_ages); Database.AddStringParam(command_count, "@SQL_PERIOD", query_period); //Execute query and get count all_results_count = Convert.ToInt32(command_count.ExecuteScalar()); //Execute query and page it IDbCommand command = connection.CreateCommand(); command.CommandText = @";WITH t AS( SELECT a.*, ROW_NUMBER() OVER(ORDER BY a.Id) AS 'RowNumber' FROM ItemType_Itemliste___ben_Skole_Produkt As a INNER JOIN ItemListRelation AS b ON a.Id = b.ItemListRelationItemId WHERE b.ItemListRelationItemListId=1" + queryWhereExtend + ") SELECT * FROM t WHERE RowNumber BETWEEN @SQL_OFFSET_START AND @SQL_OFFSET_END;"; Database.AddStringParam(command, "@SQL_TERM", query_term); Database.AddStringParam(command, "@SQL_TOPIC", query_topic); Database.AddStringParam(command, "@SQL_SUBJECT", query_subject); Database.AddStringParam(command, "@SQL_AGES", query_ages); Database.AddStringParam(command, "@SQL_PERIOD", query_period); Database.AddInt32Param(command, "@SQL_OFFSET_START", sql_offset_start); Database.AddInt32Param(command, "@SQL_OFFSET_END", sql_offset_end); //Execute query var reader = command.ExecuteReader(); //transform to datatable DataTable dt = new DataTable(); dt.Load(reader); <div class="row"> <div class="col-md-6"> <h1 class="aabenskole--product-headline">@GetGlobalValue("Global:Page.Name")</h1> </div> <div class="col-md-6"> <div class="aabenskole--paging-listpagetop pull-right"> @Paging(all_results_count, 8) </div> </div> </div> foreach (DataRow row in dt.Rows) { //dim vars string headline = row["Overskrift"].ToString(); string text = row["Tekst"].ToString(); string subject = row["Fag"].ToString(); string ages = row["Alderstrin"].ToString(); string topic = row["Emne"].ToString(); string period = row["Periode"].ToString(); string prices = row["Priser"].ToString(); string placement = row["Placering"].ToString(); string lat = ""; string lng = ""; string street = row["Street"].ToString(); string number = row["Number"].ToString(); string ZIP = row["ZIP"].ToString(); string city = row["City"].ToString(); if (!String.IsNullOrEmpty(placement)) { dynamic placement_arr = Newtonsoft.Json.JsonConvert.DeserializeObject(placement); lat = placement_arr.Lat; lng = placement_arr.Lng; } string link = row["Link"].ToString(); string image = row["Billede"].ToString(); string video = row["Video"].ToString(); //reize image string resized_image = ""; if (Pageview.Device == Dynamicweb.Frontend.Devices.DeviceType.Mobile) { resized_image = GetImageUrl(image, 730, 500); } else { resized_image = GetImageUrl(image, 730, 500); } <div class="row aabenskole--product"> <div class="col-md-12"> <div class="aabenskole--product-image" style="background-image: url(@resized_image)"> @if (!String.IsNullOrEmpty(lat) && !String.IsNullOrEmpty(lng)) { <a class="aabenskole--product-map fancybox fancybox.iframe icon" href="http://www.rksk.dk/emner/google-maps?lat=@lat&lng=@lng&street=@street&number=@number&ZIP=@ZIP&city=@city&Purge=TRUE"> &#xf041; </a> } @if (!String.IsNullOrEmpty(video)) { <img class="youtube" id="@video" src="/Files/Images/play-circle.svg" style="height:100px;opacity: 0.7; filter: alpha(opacity=40);position:absolute;top:35%;left:40%;cursor:pointer;" /> } </div> <div class="aabenskole--product-content"> <div class="aabenskole--product-border"> <h2>@headline</h2> <div class="aabenskole--product-text"> @text </div> <div class="aabenskole--product-options"> <table> <tr> <td class="aabenskole--product-options-title">Fag:</td> <td> @{ string[] subjects_arr = subject.Split(','); foreach (string word in subjects_arr) { <span class="aabenskole--product-options-selected">@HttpUtility.UrlDecode(word.Replace("Haandvaerk", "Håndværk"))</span> } } </td> </tr> <tr> <td class="aabenskole--product-options-title">Alder:</td> <td> @{ string[] ages_arr = ages.Split(','); foreach (string word in ages_arr) { <span class="aabenskole--product-options-selected">@word</span> } } </td> </tr> <tr> <td class="aabenskole--product-options-title">Emne:</td> <td> @{ string[] topic_arr = topic.Split(','); foreach (string word in topic_arr) { <span class="aabenskole--product-options-selected">@word.Replace("Miljoe", "Miljø")</span> } } </td> </tr> <tr> <td class="aabenskole--product-options-title">Periode:</td> <td> @{ string[] period_arr = period.Split(','); foreach (string word in period_arr) { <span class="aabenskole--product-options-selected">@word</span> } } </td> </tr> </table> </div> </div> <div class="aabenskole--product-price-container"> <div class="aabenskole--product-price"> <strong>Pris:</strong> @prices </div> <a href="@link" target="_blank" class="btn btn-primary aabenskole--product-btn">Se mere her</a> </div> </div> </div> </div> } } <div class="aabenskole--paging-listpagebottom pull-right"> @Paging(all_results_count, 8) </div> } </div> @if (all_results_count == 0) { <div class="h5"> - Ikke nogle l&aelig;ringstilbud i &oslash;jeblikket</div> }