Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Morten 20 posts 132 karma points
    Nov 14, 2016 @ 20:41
    Morten
    0

    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.

  • Sotiris Filippidis 286 posts 1501 karma points
    Nov 15, 2016 @ 10:09
    Sotiris Filippidis
    0

    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!

  • Morten 20 posts 132 karma points
    Nov 15, 2016 @ 20:28
    Morten
    1

    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 :)

  • Sotiris Filippidis 286 posts 1501 karma points
    Nov 15, 2016 @ 20:53
    Sotiris Filippidis
    1

    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();  
    

    And then I use its properties:

    <a class="@linkClass" href="@targetUrl" target="@target">
    

    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.

  • Morten 20 posts 132 karma points
    Nov 15, 2016 @ 21:28
    Morten
    0

    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.

    <a href="@link.Url" target="_self" class="btn btn-md btn-black">@buttonText</a>
    

    The code above here did solve my problem perfectly.

  • Sotiris Filippidis 286 posts 1501 karma points
    Nov 15, 2016 @ 22:32
    Sotiris Filippidis
    0

    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.

  • Sotiris Filippidis 286 posts 1501 karma points
    Nov 15, 2016 @ 23:05
    Sotiris Filippidis
    0

    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

  • Morten 20 posts 132 karma points
    Nov 16, 2016 @ 17:25
    Morten
    0

    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());
    
  • Sotiris Filippidis 286 posts 1501 karma points
    Nov 16, 2016 @ 17:35
    Sotiris Filippidis
    0

    Go to a blog post and publish it again to reset the cached blog helper, and see if it helps

  • Morten 20 posts 132 karma points
    Nov 16, 2016 @ 22:22
    Morten
    0

    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.

  • Sotiris Filippidis 286 posts 1501 karma points
    Nov 16, 2016 @ 22:51
    Sotiris Filippidis
    0

    Okay, it probably needs some more testing :) sorry for the trouble! Are you using tags at all?

  • Morten 20 posts 132 karma points
    Nov 16, 2016 @ 22:57
    Morten
    0

    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.

  • Sotiris Filippidis 286 posts 1501 karma points
    Nov 18, 2016 @ 22:55
    Sotiris Filippidis
    100

    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)

  • Morten 20 posts 132 karma points
    Nov 19, 2016 @ 09:45
    Morten
    1

    Perfect, it looks like it's all working now :) thanks for the fixing.

    The struggle when fixing bugs ;): http://www.dailymotion.com/video/x2gp98t

  • Sotiris Filippidis 286 posts 1501 karma points
    Nov 19, 2016 @ 10:09
    Sotiris Filippidis
    0

    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!

  • Nitin Anand 46 posts 178 karma points
    Mar 10, 2017 @ 12:39
    Nitin Anand
    0

    Hi, my blog page was working until yesterday, but today i included some files to project and then it stopped working and shows this error. which is a null exception error in english. I followed this post but go no luck. You have any clue.

  • Sotiris Filippidis 286 posts 1501 karma points
    Mar 10, 2017 @ 12:42
    Sotiris Filippidis
    0

    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.

  • Nitin Anand 46 posts 178 karma points
    Mar 10, 2017 @ 12:45
    Nitin Anand
    0

    alright: Will start a new. thanks

  • Sotiris Filippidis 286 posts 1501 karma points
    Nov 19, 2016 @ 20:00
    Sotiris Filippidis
    0

    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.

  • Sotiris Filippidis 286 posts 1501 karma points
    Nov 19, 2016 @ 20:07
    Sotiris Filippidis
    0

    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]
    
Please Sign in or register to post replies

Write your reply to:

Draft