Copied to clipboard

Flag this post as spam?

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


  • Felix 46 posts 67 karma points
    Jun 28, 2010 @ 09:31
    Felix
    0

    redirect all nodes with no template selected to a 404

    Im not entirely sure if this is possible, but currently, any node within the content tree of umbraco has a URL.

    say you have a folder called news categories under the content node, with several news categories within the folder. Each of these nodes would have a URL, but no template attached to it as we dont want to render a news category on the front end. it is merely used for categorisation purposes within the CMS.

    Ideally the web.config or similar config file wuld have  a NoTemplateAttachedURL setting where you specify what page you want the user taken to.

    Currently to overcome this issue, im setting the default value of the newstype "page redirect" property to be that of my 404 page.  id be interested to hear if anyone else has any better suggestions.

     

     

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jun 28, 2010 @ 09:40
    Dirk De Grave
    0

    I guess it's all up to decide what to do when someone is trying to browse the category node. Either a redirect to a 404 (which I don't think it's the best solution), or maybe a internal redirect to the first "news" node under that category?

     

    Cheers,

    /Dirk

     

  • John Jackson 8 posts 28 karma points
    Jun 28, 2010 @ 10:49
    John Jackson
    0

    @Dirk, yes that might be a solution in this specific case, but that still leaves the issue that when you have documents that you don't use for displaying anything, when you visit the url you don't get a 404

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jun 28, 2010 @ 10:54
    Dirk De Grave
    0

    you're right, and in that case, I'd use a general template and add some info and some links which can take you back to "real data" pages.

     

    Cheers,

    /Dirk

  • John Jackson 8 posts 28 karma points
    Jun 28, 2010 @ 11:07
    John Jackson
    0

    @Dirk, yeah that seems like a good option, and what if you want to return a 404 status code on that template?

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jun 28, 2010 @ 11:11
    Dirk De Grave
    0

    You could just insert some inline .net code to set the 404 header info in that template, just as you would do with standard asp.net / c# code

  • Thomas.R 39 posts 62 karma points
    Jun 28, 2010 @ 11:33
    Thomas.R
    0

    Hi,

    i think nodes which don't have template should trigger a 404, because a node with no template does not represent a page, its non-sense to give them an URL (a node is a content, not a page).

    You can also create an HttpModule after the umbracoRequestModule.

    /Thomas

  • Felix 46 posts 67 karma points
    Jun 29, 2010 @ 03:13
    Felix
    0

    hi all,

    thanks for all your suggestions. i agree with Thomas R, i dont think that content that should never have a URL should ever be rendered at all with any template. It should trigger a 404. Ill look into creating a HTTP module, thanks all!

     

     

     

     

  • Atoosa Khoda 96 posts 148 karma points
    Sep 19, 2012 @ 04:05
    Atoosa Khoda
    1

    I agree too, why a url should be generated for a document that doesn't have template attached to it, in the firts place? that you have to then handle 404 for them. It's like suggesting that there's a url, but please don't click on it. i think it should be in the core, not to generate a url for a node with no template.  

  • Funka! 398 posts 661 karma points
    Sep 19, 2012 @ 19:05
    Funka!
    0

    Check out U4-862: Hide Preview Button and "Link to Document" on content nodes that are not intended for display (e.g., those that have no templates) in the issue tracker and vote it up if you think this would be a good change to have in the core!

  • Jason 22 posts 41 karma points
    Nov 03, 2012 @ 03:25
    Jason
    0

    Totally agree this should be addressed and great to see it in UA-862 fix for 4.10.0.  Below is how I get around this issue.  Basically create a simple template with redirect .NET code set to the url of the parent page where all the subnode data is actually getting displayed.  This way if the content is indexed by examine then the link can show a true url but when you click it the page is redirected to the parent page.

    Below is an example template that I set the sub node document types to and set as the default template. So when a user adds a sub node it will automatically redirect to the correct page if the link is discovered.

    <%@ Master Language="C#" MasterPageFile="~/umbraco/masterpages/default.master" AutoEventWireup="true" %>

    <script type="C#" runat="server">
    protected void Page_Load(object senderEventArgs e)
    {
      Response.Redirect("/Links.aspx");
    }
    script>
      
    <asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server">
    asp:Content>

    Hope it helps someone.

    Jason

  • Stephen 767 posts 2273 karma points c-trib
    Nov 03, 2012 @ 08:54
    Stephen
    0

    Starting with 4.10 a published node with no template will trigger a 404 ie if you request /foo/bar and page bar has no template, it is treated as 404 (runs the 404 handlers, etc).

    Unless it redirects (internal or external) which is what you may want to do...

Please Sign in or register to post replies

Write your reply to:

Draft