This project is read-only.

Threads RoutePart is saving with a null Title

Oct 7, 2011 at 2:19 PM

I've tried it on a couple of different installations and wasn't able to get it to work.

It'll hit the setter of Thread.Title but the line after UpdateEditor in ThreadController (line 89), the thread.Title is null.

thread.Title = ValueProvider.GetValue("ThreadPart.Title").AttemptedValue;
putting that on line 90 fixes it, but I know it shouldn't need that. I thought it might have been because I was running 1.3, but it did it to me on 1.2 as well.

Any ideas?

thread.Title = ValueProvider.GetValue("ThreadPart.Title").AttemptedValue;
Oct 8, 2011 at 11:55 AM

Wow odd!!.. hmm... Im not sure. Im going to look t upgrade the module to 1.3 in the next couple of days.

Let me investigate a little more and get back to you. Thanks for reporting :)

Oct 8, 2011 at 11:48 PM

The same issue (I guess) I experience when try to Edit Thread by the Admin Menu. Any change in the Thread Title leads to saving thread with null title. Then the thread becomes not accessible since thread's link has a null after the parent forum part.

Oct 15, 2011 at 1:18 PM

I have just tried to edit a thread via the Admin screens in 1.3 and I dont see the same behaviour. - And ideas?

Oct 17, 2011 at 10:55 AM

I have the exact same problem with 1.3 but had it also with 1.2. Is there a quick fix for this problem?

Oct 18, 2011 at 8:37 AM

I temporary fixed it by:

thread.Title = HttpContext.Request.Form["ThreadPart.Title"];


var postModel = _orchardServices.ContentManager.UpdateEditor(post, this);

in the ThreadController.

very dirty i know but it does the job in the mean time.

Oct 19, 2011 at 10:00 PM
Edited Oct 19, 2011 at 10:01 PM

Hi Jetski5822,

Sorry for a delay with reply. To demonstrate the issue with a null title I created a test website with Orchard CMS and Forum module 0.5 installed from a scratch. Then I created a new form for testing (accessible in the main menu). Both titles issues are there. When a new post is created it is saved with null title. I already fixed it using Znowman's approach (nickspiers's one also works). However, after editing of any thread in Dashboard Admin Menu (by Manage Forums-Test Forum- Edit Thread), the thread title gets null again. To reproduce the problem, just click open thread editor in the dashboard. Then any press of the Save Button makes existing thread's title null. Renaming the title produces the same result.

If you like to see this issue in action, use an dedicated admin account on the test website (name:  test password: testtest ) I am going to keep the site working for while. I will be grateful for any suggestions in fixing it.


Oct 19, 2011 at 10:06 PM

Oh wow! the bug is in the admin screens!!! okay I see it it. Thanks for the Repo Corvex - good steps. Will take a look at this.

Nov 10, 2011 at 12:07 PM

I've made some progress on at least finding WHERE the issue is. Bear with me here, haha.

I placed a breakpoint on the ThreadPart.Title setter, which is hit on thread creation

If I then start stepping through the process the thread holds its title UNTIL Orchard invokes the driver for Orchard.Core.Routable.Drivers.RoutePartDriver

At this point the thread's title is set to null. Will keep digging but hopefully that will light a bulb for someone.

Nov 10, 2011 at 3:16 PM

Was able to get it working as expected. Because the RoutePartDriver was overriding the Title after the ThreadPartDriver set it, I changed the EditorTemplate for Parts.Routable.ThreadPart to post as Routable.Title instead of ThreadPart.Title by manually creating the input field. So the full cshtml looks like:

@model NGM.Forum.Models.ThreadPart

   @Html.LabelFor(m => m.Title, T("Title"))
   <input type="text" id="Routable_Title" class="large text" name="Routable.Title" value="@Model.Title" />
The Html.TextBox wouldn't work because it kept prepending Thread_ to the input's name.

Nov 16, 2011 at 1:44 PM

Even better solution: embrace the RoutePart's editor. Change the line suppressing the Parts_Routable_Edit to Content:before.5 and remove/suppress the Pars_Routable_Thread_Edit line.

ThreadPartDriver GET Editor method: you can remove the Parts_Routable_Thread_Edit ContentShape from the CombinedResult.

Views/EditorTemplates: Delete the Parts.Routable.ThreadPart.cshtml view and create a Parts.Routable.RoutePart.cshtml view.

and here's the kicker that got me hung up for a while:

Module.txt: Add a dependency on Routable

I've created a fork with all these changes. I want to play around with it a little bit more, but man was this a learning experience!

Nov 16, 2011 at 6:44 PM

Hey dude,

Thanks for tracking it down. Let me know when you are realy to do a pull reqeust and I will pull your changes in to the main repo :)

Yeah Orchard is a mighty beast to learn!!

Nick :)

Nov 21, 2011 at 11:26 AM

Pull requested, I think I've got it all trimmed to what's needed.

Nov 21, 2011 at 11:28 AM

we are looking forward to a new release :)

Dec 9, 2011 at 11:43 AM

Hey Nick, I have taken your patch. Thanks for you submission. Its on the branch now.

Jan 28, 2012 at 7:48 AM

wow. i'm glad i stumbled on this post. i was looking into this for several hours trying to figure out why the title wouldn't save.

took the latest download and applied said patches and now it works...phew!

just started orchard a couple of days ago and i know a lot more about the underlying framework than i expected to at this juncture just by trying to hunt down this problem.

thanks for your hard work on this module. it's helpful.