It looks like you only can use two categories under the blog. I made 3, but when i assign a blogpost to the 3 category, the category stays empty at my site.
Another question, if you add an external link. Is it possible to make it open in the same windows?. I like to add a link to my blog with a category on - so i can make links from my homepage directly to the blog with a category.
I know i can use internal links, but they can only link to pages, not a specific
page with a category on like: http://website/blog/?c=1391
Hope you understand it :) and can come up with an answer.
I haven't noticed anything wrong with blog categories (except from a bug with the category picker which doesn't use the categories node as the start node - noted). I tested it myself and I was able to add 3 categories and assign a blog post to all 3 and also see all 3 categories' contents. Maybe there's something else going on there?
About external links - at the moment, no. External links always open in a new window, although you're right - you SHOULD be able to specify such a link (which is, essentially, an "internal" link) and have it open in the same browser window.
I can see two workarounds in that: The first would be to add a checkbox to the link tab, asking if you want the link to open in a new window instead of having it automatically defined. The second would be a clever template for categories which would redirect to the blog's url with the category id as parameter - this would let you truly specify an internal link (the category node) which opens in the same browser window by default.
I found the problem in the blog/categories. It looks like its making a list with all blog post, so when i have 15 blog post it makes 3 pages. If i then pick a category it still use the same list, so the first page can be empty, and then i have 2 posts at page 2 and 1 post at page 3. Because its sorted like if it showed all 15 posts, i think.
Okay, i will just use the external link for now then. I can't find the place in the code where the link is set to open in a new window.
Wow, this is serious! Thank you for noticing, I'll try to fix this asap.
Now, about the code: This part of the code is something I've been using in other projects and I haven't given away the code - it's in the DotSee.Common DLL file. Generally, though, you get a LinkItem object via the .GetLink() extension method. This object has two properties: targetUrl (which is the link url) and target (which has either the value "blank" or the value "self")
If you still want to change it, you can go to the partial view that you are using, e.g. SectionStatement.cshtml for the Statement section, find where it's used and replace it with a hardcoded value. For example, in SectionStatement.cshtml, I first get the link:
SectionStatement currSection = Model;
//Other things...
LinkItem link = currSection.GetLink();
You can either omit the whole target attribute or replace @target with _self and every link, be it external or internal, will open in the same browser window. You will have to do it per partial view though.
No problem, i'm just glad to help a little. The problem is the same with tags. Hope you will get time to fix it, so the categories and tags is going to work 100%.
I'm working on it right now. I noticed that tags had exactly the same problem. I can't believe I wrote such shitty code there, but then it happens to everybody at some point in time, doesn't it? :)
I hope I'll have some sort of patch for this very soon.
I replaced the 2 flies, and gets an error when i try to go to the blog page.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 9: public static BlogHelper GetCachedBlogHelper(ApplicationContext cx, PageBlogList blogRoot)
Line 10: {
Line 11: return (BlogHelper)cx.ApplicationCache.RuntimeCache.GetCacheItem(string.Format("blogHelper{0}", blogRoot.Id.ToString()), () => new BlogHelper(blogRoot));
Line 12: }
Line 13: }
In Visual studio it popup in the BlogHelper with:
An exception of type 'System.NullReferenceException' occurred in App_Code.ye95crgq.dll but was not handled in user code.
foreach (var t in allTags) {
_tagItemCount.Add(t.Text, _postItems.Where(x => x.Tags.ToString().Split(',').Contains(t.Text)).Count());
yes, I used tags at my real blog posts.
But at the testing blog I made, I didn't add tags, and still got the error, don't know if it is using the same.
Great! So I'm going to test it some more and then I'm going to release an "official" patch as well as a new version for the theme. Thanks for your help!
I will need a lot more information to find out what's going on. In the meantime, try touching your web.config to restart the application and make the blog helper reload its data. It would also be better to start a new thread since this one has already been answered.
I've uploaded a patch containing the fixes we already discussed here, as well as a fix for the category picker which would not set the blog categories as its start node.
Aaaand I discovered (in horror!) that if the data type already exists, it won't update it. Strange.
In any case, if you want to have the complete fix for this, you can go and find the "Custom_CategoryPicker" data type and replace the xpath for the start node with this:
$current/ancestor-or-self::node()[@isDoc and (@parentID = $current/ancestor-or-self::folderSections[1]/@id or @id= $current/ancestor-or-self::pageBlogList[1]/@id) ][1]/folderGenericCategories[1]
Blog categories
First of all, thanks for an awesome template :)
It looks like you only can use two categories under the blog. I made 3, but when i assign a blogpost to the 3 category, the category stays empty at my site.
Another question, if you add an external link. Is it possible to make it open in the same windows?. I like to add a link to my blog with a category on - so i can make links from my homepage directly to the blog with a category.
I know i can use internal links, but they can only link to pages, not a specific page with a category on like: http://website/blog/?c=1391
Hope you understand it :) and can come up with an answer.
Thank you Morten!
I haven't noticed anything wrong with blog categories (except from a bug with the category picker which doesn't use the categories node as the start node - noted). I tested it myself and I was able to add 3 categories and assign a blog post to all 3 and also see all 3 categories' contents. Maybe there's something else going on there?
About external links - at the moment, no. External links always open in a new window, although you're right - you SHOULD be able to specify such a link (which is, essentially, an "internal" link) and have it open in the same browser window.
I can see two workarounds in that: The first would be to add a checkbox to the link tab, asking if you want the link to open in a new window instead of having it automatically defined. The second would be a clever template for categories which would redirect to the blog's url with the category id as parameter - this would let you truly specify an internal link (the category node) which opens in the same browser window by default.
Thinking about it!
I found the problem in the blog/categories. It looks like its making a list with all blog post, so when i have 15 blog post it makes 3 pages. If i then pick a category it still use the same list, so the first page can be empty, and then i have 2 posts at page 2 and 1 post at page 3. Because its sorted like if it showed all 15 posts, i think.
Okay, i will just use the external link for now then. I can't find the place in the code where the link is set to open in a new window.
Thanks for fast answer :)
Wow, this is serious! Thank you for noticing, I'll try to fix this asap.
Now, about the code: This part of the code is something I've been using in other projects and I haven't given away the code - it's in the DotSee.Common DLL file. Generally, though, you get a LinkItem object via the .GetLink() extension method. This object has two properties: targetUrl (which is the link url) and target (which has either the value "blank" or the value "self")
If you still want to change it, you can go to the partial view that you are using, e.g. SectionStatement.cshtml for the Statement section, find where it's used and replace it with a hardcoded value. For example, in SectionStatement.cshtml, I first get the link:
And then I use its properties:
You can either omit the whole target attribute or replace @target with _self and every link, be it external or internal, will open in the same browser window. You will have to do it per partial view though.
No problem, i'm just glad to help a little. The problem is the same with tags. Hope you will get time to fix it, so the categories and tags is going to work 100%.
Thanks for the code explanation.
The code above here did solve my problem perfectly.
I'm working on it right now. I noticed that tags had exactly the same problem. I can't believe I wrote such shitty code there, but then it happens to everybody at some point in time, doesn't it? :)
I hope I'll have some sort of patch for this very soon.
I put something together with minimum testing, but I think it'll do. If you're in a hurry, try replacing the two files contained in the zip file:
App_Code/Blog/BlogHelper.cs
App_Code/Controllers/PageBlogListController.cs
(keep your old files in case it doesn't work as it should!)
Your feedback will be valuable, if it works without problems I'll issue a proper patch and a new version of the theme containing this fix.
Download (temporarily) from here: https://dl.dropboxusercontent.com/u/4768755/Mazel/blogpatch.zip
I replaced the 2 flies, and gets an error when i try to go to the blog page.
In Visual studio it popup in the BlogHelper with: An exception of type 'System.NullReferenceException' occurred in App_Code.ye95crgq.dll but was not handled in user code.
Go to a blog post and publish it again to reset the cached blog helper, and see if it helps
I still got the same problem, after republishing. Also tried Ctrl+F5 and clean/rebuild solution.
And if i make a new Blog post list page with posts, it's gives the same error.
Okay, it probably needs some more testing :) sorry for the trouble! Are you using tags at all?
yes, I used tags at my real blog posts. But at the testing blog I made, I didn't add tags, and still got the error, don't know if it is using the same.
That's what you get when you fix one bug in a hurry, you introduce a couple more bugs :)
It was missing a simple check for whether tags property is null. If you still have the patience, try patching again with this one: https://dl.dropboxusercontent.com/u/4768755/Mazel/blogpatch2.zip
(actually, only the bloghelper.cs file has changed, but I'm sending both files again in the zip to avoid confusion)
Perfect, it looks like it's all working now :) thanks for the fixing.
The struggle when fixing bugs ;): http://www.dailymotion.com/video/x2gp98t
Hahaha, yes I know this clip :)
Great! So I'm going to test it some more and then I'm going to release an "official" patch as well as a new version for the theme. Thanks for your help!
I will need a lot more information to find out what's going on. In the meantime, try touching your web.config to restart the application and make the blog helper reload its data. It would also be better to start a new thread since this one has already been answered.
alright: Will start a new. thanks
I've uploaded a patch containing the fixes we already discussed here, as well as a fix for the category picker which would not set the blog categories as its start node.
Aaaand I discovered (in horror!) that if the data type already exists, it won't update it. Strange.
In any case, if you want to have the complete fix for this, you can go and find the "Custom_CategoryPicker" data type and replace the xpath for the start node with this:
is working on a reply...