I always like to learn from other developer's code; in looking through the Dialogue source, I see there are several "service" classes like Memberservice, TopicService, etc. I am curious what the benefit is for not having them as static classes? They all appear to be stateless, and their methods also appear to be pretty threadsafe.
Design Question ( *Service classes)
ApplicationEventHandler ContentService.Publishing keeps executing over and over
Hi! I'm making an event that will automatically sort pages of the type "CalendarEventPage". For doing this I get all the pages and sort them on a custom property called "StartDate". Finally, I call the method "ContentService.Sort" that will sort the pages. However, as soon as that line is executed the method starts all over again.
At first I thought it triggered a publish event for the other pages but it is the same page the event is fired for.
Does anyone have any idea why this is happening, am I missing something?
Thanks!
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
ContentService.Publishing += ContentService_Publishing;
}
private void ContentService_Publishing(IPublishingStrategy sender, PublishEventArgs<IContent> e)
{
var currentPage = e.PublishedEntities.FirstOrDefault();
Debug.WriteLine("CurrentPage: " + currentPage.Name);
if (currentPage != null && currentPage.ContentType.Alias == "CalendarEventPage")
{
var parent = currentPage.Parent();
if (parent.ContentType.Alias == "CalendarEventListingPage")
{
var children = parent.Children();
if (children != null && children.Any())
{
var calendarEvents = children.Where(x => x.ContentType.Alias == "CalendarEventPage");
var sortedCalendarEvents =
calendarEvents.OrderByDescending(x => x.GetValue<DateTime>("StartDate"));
// This line fails!
var results = ApplicationContext.Current.Services.ContentService.Sort(sortedCalendarEvents);
}
}
}
}
Erratic results with Lucene Spatial
I have inherited two sites from two different clients and both seem to have the same issue. They implement a spacial search based on this article:
https://www.leapinggorilla.com/Blog/Read/1010/spatial-search-in-lucenenet---worked-example
The issue is that results are erratic. One result appears for a 10km distance but not for 100km for instance, which obviously is wrong.
Some investigation took me to the point where it seems that Lucene 3.x spatial is deprecated and it doesn't work very well but Umbraco doesn't accept Lucene >= 3.0.0
Does anyone know if this is a known issue?. Any workarounds appreciated.
thanks.
Problem with Merchello checkout
Hi,
We're building a shop using Merchello using FastTrack as a base. I've got almost everything running but when I try to build the Checkout I run into a problem.
In my view I use:
@Html.Action("BillingAddressForm", "CheckoutAddress", new { area = "Merchello" })
but when I run it I get the yellow screen saying "No route in the route table matches the supplied values."
Do I call the wrong method or do I forget something?
Migrate Media library from a server to another server
Hello,
I'm trying to migrate the media library from a development site to a production site but I don't know how. I tried to copy the media folder from the dev site to the prod site. The files appear on the file browser but not on Umbraco.
Does anyone have ideas?
Umbraco no responding after application pool recycle.
We're running a single Umbraco site on a dedicated server. It's been running perfectly well but when the application pool recycled at 16:00 on Friday the site didn't come back up until IIS was reset. The application pool recycle was the 29 hour interval recycle set in the application pool advanced settings.
I scheduled the pool to recycle in the early hours of this morning and again Umbraco failed. IIS was running, the application pool was started but requests to the Umbraco site timed out.
Windows Server 2012 R2 - fully patched. Umbraco 7.5.3
On Friday the trace logs showed: Date Fri, 19 May 2017, 16:48:31 Level ERROR Logger Umbraco.ModelsBuilder.Umbraco.PureLiveModelFactory Process 7144 Thread 11 App Domain 2 Message Failed to build models. System.Threading.ThreadAbortException: Thread was being aborted. at System.Threading.Monitor.Enter(Object obj)
Date Fri, 19 May 2017, 16:48:31 Level WARN Logger Umbraco.ModelsBuilder.Umbraco.PureLiveModelFactory Process 7144 Thread 11 App Domain 2 Message Running without models.
Date Fri, 19 May 2017, 16:48:31 Level ERROR Logger Umbraco.Core.UmbracoApplicationBase Process 7144 Thread 8 App Domain 2 Message An unhandled exception occurred System.Web.HttpParseException (0x80004005): Key cannot be null. Parameter name: key ---> System.ArgumentNullException: Key cannot be null. Parameter name: key at System.Collections.Specialized.ListDictionary.set_Item(Object key, Object value)
The failure this morning showed the same errors plus the following: Date Tue, 23 May 2017, 03:00:26 Level ERROR Logger UmbracoExamine.DataServices.UmbracoLogService Process 4260 Thread 16 App Domain 2 Message Provider=ExternalIndexer, NodeId=-1 System.Exception: Cannot index queue items, the index is currently locked,, IndexSet: ExternalIndexSet
Any help would be greatly appreciated as I'm puzzled why this has suddenly started happening.
Problems with umbraco:item recursive and useIfEmpty attributes
Hi everyone,
I've tested this in v7.5.2 and v7.5.13
<umbraco:Item field="content" recursive="false" textIfEmpty="test" runat="server" />
The recursive
option was not set originally, but the page still displayed the value contained in the parent page field when viewed in the browser. I tried setting the attribute to recursive="false"
but it still displayed the value in the parent page.
I tried using the textIfEmpty
attribute but this didn't work either, the umbraco:item
continued to output the value in the parent page.
So, what did work was to put the following into the page content field (which I should mention is an RTE field): <p>‌</p>
i.e. it stopped the parent page field from being output.
Frontend update member with surfacecontroller
There are good examples of how creating contact form using surfacecontroller, but find little about how to update registered member information for members logged in from frontend.
Does anyone have a complete CRUD example of using model, surfacecontroller and view, using extended member profiles?
Argument 'MyPluginEditController' is not a function, got undefined
I created a new custom section in my umbraco based on this article: http://www.enkelmedia.se/blogg/2013/11/22/custom-sections-in-umbraco-7-%E2%80%93-part-2-the-views.aspx
I'm trying to move angular controller to a separate file similar to this solution but I'm getting an error as in the subject:
Argument 'MyPluginEditController' is not a function, got undefined
I don't know angular.js so I am not very sure what I'm doing but I don't think at this stage it would be too difficult. Yet for some reason my app cannot find the controller.
So far I have myplugin.manifest
:
{
javascript: [
'~/App_Plugins/MyPlugin/backoffice/myPluginTree/edit.controller.js',
'~/App_Plugins/MyPlugin/contact.resource.js'
]
}
edit.html
view:
<div ng-controller="MyPluginEditController">
<umb-panel>
<umb-header tabs="content.tabs">
<div class="umb-headline-editor-wrapper span12 ng-scope">
<h1 class="ng-binding">MyPlugin section {{id}}</h1>
</div>
</umb-header>
<umb-tab-view>
<umb-tab id="tab1" rel="svensson">
<div class="umb-pane">
This is tab content for tab 1<br />
<p ng-show="EditMode()">
<span class="label label-warning">In create mode, this label is only showed when the controller sees the create-querystring item.</span>
</p>
</div>
</umb-tab>
<umb-tab id="tab2" rel="kalle">
<div class="umb-pane">
This is tab content for tab 2
</div>
</umb-tab>
</umb-tab-view>
</umb-panel>
</div>
and edit.controller.js
:
angular.module("umbraco").controller("MyPluginEditController",
function ($scope, $routeParams, personResource, notificationsService, navigationService) {
$scope.content = { tabs: [{ id: 1, label: "Tab One" }, { id: 2, label: "Tab Two" }] };
$scope.EditMode = function () {
return $routeParams.create == 'true';
};
});
The contact.resource
just has this (which is not used yet):
angular.module("umbraco.resources")
.factory("contactResource", function ($http) {
return {
getById: function () {
return $http.get("MyPlugin/Contact/GetAll");
}
};
});
In addition id in the header MyPlugin section {{id}}
doesn't show up. I thought it would show up the menu item id? But the header shows just MyPlugin section
What am I doing wrong?
Contact form - cannot bind source type to model type
Hi,
New to Umbraco so built a contact form with a tutorial. When I deployed the site to Azure the first time (with an sdf database sitting in AppData) I got the error "cannot bind source type to model type". I managed to fix it by changing ModelsBuilder.ModelsMode to AppData in the web.config file and it works fine.
As an exercise I then created a second web app in Azure but moved the database to Azure's sql database. Connection string works, but I get the same error "cannot bind source type to model type" now that I can't seem to fix.
I'm not sure why I'm getting the error (i.e. what I've coded that causes the issue) but also how to fix it.
I understand the error is due to my contact form. Here's the code. Any help appreciated
Html.Action("ShowForm", "ContactSurface")
Contact form partial view
@inherits Umbraco.Web.Mvc.UmbracoViewPage<EsportsGold.standardwebsite.ContactModel>
@using (Html.BeginUmbracoForm<EsportsGold.standardwebsite.ContactSurfaceController>("HandleFormPost"))
{
<div id="contactForm">
<label for="emailFrom"></label>@Html.TextBoxFor(x => x.Email, new { @class = "emailFrom", placeholder = "Your Email" })
<br />
<label for="contactName"></label>@Html.TextBoxFor(x => x.Name, new { @class = "contactName", placeholder = "Name" })
<br />
<label for="contactTopic"></label>@Html.TextBoxFor(x => x.Topic, new { @class = "contactTopic", placeholder = "Topic" })
<br />
<label for="contactText"></label>
<br />
@Html.TextAreaFor(x => x.Message, new { @class = "contactText", placeholder = "Message" })
<br />
<input type="submit" value="Submit" />
</div>
}
ContactSurfaceController
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Mvc;
using Umbraco.Web.Mvc;
using System.Linq;
using System.Xml.XPath;
using Umbraco.Core.Services;
namespace EsportsGold.standardwebsite
{
public class ContactSurfaceController : SurfaceController
{
public ContactSurfaceController()
{
}
public ActionResult ShowForm() {
ContactModel myModel = new ContactModel();
List<SelectListItem> ListOfGames = new List<SelectListItem>();
XPathNodeIterator iterator = umbraco.library.GetPreValues(1089);
iterator.MoveNext();
XPathNodeIterator preValues = iterator.Current.SelectChildren("preValue", "");
while (preValues.MoveNext()){
string preValue = preValues.Current.Value;
ListOfGames.Add(new SelectListItem {
Text = preValue,
Value = preValues.Current.GetAttribute("id", "")
});
myModel.ListOfGames = ListOfGames;
}
return PartialView("ContactFormView", myModel);
}
public ActionResult HandleFormPost(ContactModel model){
var newComment = Services.ContentService.CreateContent(model.Name + " - " + DateTime.Now, CurrentPage.Id, "ContactForm");
newComment.SetValue("umbracoNaviHide", false);
newComment.SetValue("emailFrom", model.Email);
newComment.SetValue("contactName", model.Name);
newComment.SetValue("contactText", model.Message);
newComment.SetValue("contactTopic", model.Topic);
Services.ContentService.SaveAndPublishWithStatus(newComment);
return RedirectToCurrentUmbracoPage();
}
}
}
Umbraco Forms - Date Picker js error
Using Umbraco v7.6.1, Forms v6.0.1
Hi,
I have 2 forms on the same page that both use a date picker, when I select a date on one of the forms the page locks, here is a sample of the errors i'm getting:
pikaday.js:64 Uncaught RangeError: Maximum call stack size exceeded.
at fireEvent (pikaday.js:64)
at Pikaday.setDate (pikaday.js:647)
at HTMLInputElement.Pikaday.self._onInputChange (pikaday.js:429)
at fireEvent (pikaday.js:64)
at Pikaday.setDate (pikaday.js:647)
at HTMLInputElement.Pikaday.self._onInputChange (pikaday.js:429)
at fireEvent (pikaday.js:64)
at Pikaday.setDate (pikaday.js:647)
at HTMLInputElement.Pikaday.self._onInputChange (pikaday.js:429)
at fireEvent (pikaday.js:64)
at Pikaday.setDate (pikaday.js:647)
Date picker works fine when there is only one on the page. Any suggestions of how to fix?
Thanks
Kerri
Modify Umbraco's web api route?
By default, Umbraco's web api controllers uses the following route: ~/Umbraco/Api/[YourControllerName]
.
The documentation states: "Just like Surface Controllers in Umbraco, when you inherit from the base class Umbraco.Web.WebApi.UmbracoApiController
we will auto-route this controller so you don't have to worry about routing at all."
What if I want to use another route? In my case I would like to use ~/Api/v1/[ControllerName]
. Is this possible?
Doc2Form not saving File Uploads
I had Doc2Form working nicely on LondonScc.co.uk enabling members to upload their profile to our members area. All working fine with the ability to upload pictures and pdfs.
I've had a few server issues recently, moved the site to a new server and now the Uploads have stopped working. No error messages in the Event Log or in umbracoLog table.
Any ideas about settings I might have missed, or changes that a move from Server 2003 to 2008 R2 might have had.
Can you use .NET MVC in Umbraco 7 Backoffice
Can you use .NET MVC in Umbraco 7's Back Office? I believe this was a possibility in earlier versions of Umbraco, but based on what I have seen, it appears that you need to use normal HTML and AngularJS.
Is there a way to use .NET MVC? I don't see any way to tell the back office what URL to use for a Tree item.
Partial view form causes all layout to disappear
I listened to all Umbraco videos and I am now trying to apply my knowledge. This video talks of partial views as a means to present custom data. http://umbraco.tv/videos/developer/fundamentals/surface-controllers/handling-posts/
Most of it works, but I am a bit confused. I retrieve data from MediaService to list audio files in different subfolders. The data is presented OK. Then I want to allow the user to swap to another folder by changing a DropDownlist. Then everything goes wrong.
1) First I am a bit confused on how to trigger on Dropdown change. Should I use jQuery or can Razor helpers help me?
2) Right now I use a button to trigger new selection. It kind of works. The new data is rendered all right, but all of my layout disappears! The master page with all menus and styling is gone.
I guess it all boils down to how partial views work together with templates and document types when posting data in the form. It seems that I lost track somewhere ... :)
Any help very much appreciated!
Controller
public class AudioListSurfaceController : SurfaceController
{
public ActionResult Index()
{
var audioListModel = new AudioListModel();
var sermonFolder = GetSermonFolder();
if (sermonFolder != null)
{
audioListModel.YearFolderNames = sermonFolder.Children().Select(f => f.Name).ToList();
audioListModel.YearFolderName = audioListModel.YearFolderNames.OrderByDescending(x => x).FirstOrDefault();
}
return Search(audioListModel);
}
[HttpPost]
public ActionResult Search(AudioListModel audioListModel)
{
var sermonFolder = GetSermonFolder();
if (sermonFolder != null)
{
audioListModel.YearFolderNames = sermonFolder.Children().Select(f => f.Name).ToList();
var yearFolder = sermonFolder.Children().SingleOrDefault(f => f.Name == audioListModel.YearFolderName);
if (yearFolder != null)
{
foreach (var mediaItem in yearFolder.Children())
{
audioListModel.AudioModels.Add(new AudioModel
{
Title = mediaItem.Name,
Author = mediaItem.GetValue<string>("author"),
Date = mediaItem.GetValue<DateTime>("date"),
Location = mediaItem.GetValue<string>("location"),
Size = mediaItem.GetValue<string>("size"),
SizeBytes = mediaItem.GetValue<int>("sizeBytes"),
Duration = TimeSpan.FromSeconds(mediaItem.GetValue<int>("durationSeconds")),
Path = mediaItem.GetValue<string>("umbracoFile"),
});
}
}
}
return PartialView("AudioListForm", audioListModel);
}
private IMedia GetSermonFolder()
{
var sermonFolder = Services.MediaService.GetRootMedia().FirstOrDefault(folder => folder.ContentType.Alias == "audioFolder" && folder.Name == "Predikningar");
return sermonFolder;
}
}
Partial View
@using Sandeslatt.Controllers
@model Sandeslatt.Models.AudioListModel
@using (Html.BeginUmbracoForm<AudioListSurfaceController>("Search"))
{
@Html.DropDownListFor(m => m.YearFolderName, Model.GetYearFolderNames(Model.YearFolderName), new {@class = "form-control"})
<button type="submit" class="btn btn-primary">Sök</button>
}
<table class="table table-bordered table-condensed table-striped table-nonfluid">
<tr>
<th>Datum</th>
<th>Titel/Talare</th>
<th class="text-center">Längd</th>
<th class="text-center">Storlek</th>
<th class="text-center">Spela</th>
<th class="text-center">Ladda ner</th>
</tr>
@foreach (var audioModel in Model.AudioModels.OrderByDescending(a => a.Date))
{
<tr>
<td>@audioModel.Date.ToString("yyyy-MM-dd")</td>
<td>
<strong>@audioModel.Title</strong><br/>
@audioModel.Author
</td>
<td class="text-right">@audioModel.DurationDisplay</td>
<td class="text-right">@audioModel.Size</td>
<td> </td>
<td> </td>
</tr>
}
</table>
Hosting Template
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage<ContentModels.AudioList>
@using ContentModels = Umbraco.Web.PublishedContentModels;
@{
Layout = "Master.cshtml";
}
@Html.Action("Index", "AudioListSurface")
Upgrading Umbraco fails [7.1 -> 7.6.1]
* Reported in the issue tracker * http://issues.umbraco.org/issue/U4-9927
I'm trying to upgrade an Umbraco 7.1 installation to 7.6.1 (direct upgrade), however - the installer fails due to missing columns in various tables. I made a fresh 7.6.1 install and compared the two databases and found that the upgrade fails to add the following:
Table UmbracoPropertyTypeGroup: column uniqueID, type: uniqueIdentifier, not null
Table UmbracoRelationType: column typeUniqueId, type: uniqueIdentifier, not null
Fixed the steps manually, now I'm getting this error: The database failed to upgrade. ERROR: The database configuration failed with the following message: The index 'IX_umbracoNodeUniqueID' is dependent on column 'uniqueID'. ALTER TABLE ALTER COLUMN uniqueID failed because one or more objects access this column.
How do I fix this? Anyone else having this kind of problem?
Sitemap time out
The sitemap generated by SEO Checker has started timing out. If I extend the timeout the you do eventually get the sitemap with 3000+ urls in it.
Do you believe SEO Checker should be able to produce this sitemap in a timely manner, or should I use something custom to resolve this?
I'm using Umbraco 7.5.7 and SEO Checker 1.9.4.
Extending Grid Editor Properties
Fellow umbracians....
Is it possible to add custom data properties in to the grid editor without compromising the ability to upgrade and ultimately overwrite your additions?
If so how do I go about this?
Thanks in advance
Problem with saving extended content on Master product after creating variants
Hi Rusty,
I ran into a problem, which i think is a bug. Yesterday I started a new project with umbraco, merchello and fasttrack. Added the Dutch language and deleted the English language.
When i create a product, and change the 'brief' or 'description' and save, on the front-end it changes to the new text. The moment i create variants for that product, and for example change the 'brief' on the Master product it doesn't save. It looks like it does, but after restarting the project it changed back to the previous text.
I do get this error however when i press 'Save' the first time:
And when I press 'Save' the second time (without changing pages)
Thanks!
Add new Workflow to forms not showing in CMS
Hi,
I have created a new class and added the code which creates a new Workflow for Forms. When I release the DLL to the site the Workflow is NOT showing in the Configure Workflow section of the CMS.
Am I missing something?
Jon