Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Set the layout of the main page (i.e. the one you want to redirect from) to be an ashx generic handler. That would mean there is not UI code involved in any way.</p> <p>You can do it with a lot less code, as long as the following assumptions are true: 1. All child items are newsletters 2. The latest is at the top (e.g. items are sorted by release date)</p> <pre class="lang-cs prettyprint-override"><code>namespace YourSite { public class NewsletterHandler : IHttpHandler { public void ProcessRequest(HttpContext context) { Item item = Sitecore.Context.Item.Children[0]; string url = Sitecore.Links.LinkManager.GetItemUrl(item); context.Response.Redirect(url); } public bool IsReusable { get { return false; } } } } </code></pre> <p>If the assumptions above are wrong, finding the latest published may not be as simple as getting the publish date as described by Zooking. It may be, but if you make a fix to an older newsletter and re-publish, that code may fail (i think?). If it's fine, no problem, Zooking is correct, otherwise you may want to actual give each newsletter a specific date field .. in that case, use the code here in your handler.</p> <pre class="lang-cs prettyprint-override"><code>namespace YourSite { public class NewsletterHandler : IHttpHandler { public void ProcessRequest(HttpContext context) { Item[] children = Sitecore.Context.Item.Axes.GetDescendants(); Item item = children.AsQueryable() .Where(c =&gt; c.TemplateName.ToLower() .Contains("newsletter")) .OrderByDescending(c =&gt; DateTime.Parse(c["PublishDate"])).FirstOrDefault(); string url = Sitecore.Links.LinkManager.GetItemUrl(item); context.Response.Redirect(url); } public bool IsReusable { get { return false; } } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload