Developer forum

Forum » Development » Tags to related news item

Tags to related news item

Magni J. Hansen
Reply

Is it possible to set new tags to related items.

I want to put an image to related news items.


Why is this (private static List<int> GetRelatedNewsIds(int parentId, int top)) method private ? 

Replies

 
Magni J. Hansen
Reply
This post has been marked as an answer

This did the trick:
public class NewsExtender : NewsItemDetailsTemplateExtender
    {
        public override void ExtendTemplate(Dynamicweb.Rendering.Template t)
        {
            if (t.LoopExists("News:RelatedNews"))
            {
                int newsid = Input.FormatInteger(Base.Request("NewsID"));
                string sortOrder = "DESC";
                string sortOption = "NewsDate";

                var relatedlist = Dynamicweb.Modules.News.NewsItem.GetRelatedNews(base.Item.NewsCategoryID.ToString(), newsid, 3,
                    NewsItem.NewsStatus.Active, new System.Collections.ArrayList(), ref sortOrder, ref sortOption).ToList();
                foreach (var item in relatedlist)
                {
                    Dynamicweb.Rendering.Template related = t.GetLoop("News:RelatedNews");
                    related.SetTag("News:NewsSmallImage", item.NewsSmallImage);
                    related.SetTag("News:NewsImage", item.NewsImage);
                    related.SetTag("News:NewsImageText", item.NewsImageText);
                    related.SetTag("News:Link", item.NewsLink);
                    related.SetTag("News:NewsHeading", item.NewsHeading);
                    related.SetTag("News:NewsID", item.ID);
                    related.SetTag("News:NewsLinkPopup", item.NewsLinkPopup);
                    related.SetTag("News:NewsDate", item.NewsDate);
                    related.SetTag("News:NewsManchet", item.NewsManchet);

                    string href = "Default.aspx?ID=" + Input.FormatInteger(Base.Request("ID"));
                    if (Input.FormatInteger(Base.Request("Action")) != 0)
                    {
                        href += "&Action=" + Input.FormatInteger(Base.Request("Action"));
                    }

                    href += "&NewsId=" + item.ID;

                    if (Input.FormatInteger(Base.Request("PID")) != 0)
                    {
                        href += "&PID=" + Input.FormatInteger(Base.Request("PID"));
                    }

                    related.SetTag("News:Href", href);
                    related.CommitLoop();
                }
            }

            base.ExtendTemplate(t);
        }
    }

Votes for this answer: 0

 

You must be logged in to post in the forum