2 Replies Latest reply on Mar 20, 2013 1:01 PM by alexchen2013

    How to get related articles?

    alexchen2013 Level 1


      I have a blog on my site. If I want to display 5 related articles on the bottom of each blog posts, how I can achieve? I have an idea of adding Tags to each post manually, and display the ones with the same Tags as related articles. But it looks like there is no this type of short code to archieve. Any ideas?

        • 1. Re: How to get related articles?
          Alex Pavelescu Adobe Employee



          You can assign categories to both news items and blog posts.In the blog module templates you can display {tag_categorylist} in order to generate each assigned category. It will be rendered as a list inside a div, like this:

          <div class="blogpostcategories">

          <ul>   <li>     <a title="Category one" href="/BlogRetrieve.aspx?BlogID=9216&amp;CategoryID=76735">Category one <span>(1)</span></a>



                    <li>     <a title="Category two" href="/BlogRetrieve.aspx?BlogID=9216&amp;CategoryID=76736">Category two <span>(1)</span></a>





          So you now have your category ids available. With some js you can grab those categories and use them in displaying announcements:

          {module_announcement,cl,76736,,ajax,,,,,1} - will display the 1 latest announcement in category 76736

          Regarding the js method for grabbing the category id, if you're using the split() method, splitting the href attribute of the link by "=" (www.w3schools.com/jsref/jsref_split.asp) in a way similar to: var n=str.split("="); [where the str is a variable to which you assign the value of the href attribute of the link] will turn n into a string with these values: /BlogRetrieve.aspx?BlogID, 9216&amp;CategoryID, 76736. So you know that n[2] is your category ID. So you could use the script to wite something like:



          var div = document.getElementById('A DIV'S ID');

          div.innerHTML = '{module_announcement,cl,' + n[2]+ ',,ajax,,,,,1}';


          Kind Regards,


          • 2. Re: How to get related articles?
            alexchen2013 Level 1

            Wow, thx so much for your great post.