6 Replies Latest reply on May 5, 2008 12:18 PM by georgev63

    How to create "related articles"?

      Hi everyone!
      I am working on a CMS, sports news and events articles... using CS3 and ADDT of course!
      Everything works fine until now but i would like to improve my CMS with "related articles" on the main article, something like this for exemple:
      http://www.cnn.com/
      main article is "Poll: Bush disapproval rating highest on record" and some related articles, (the two link "Obama support..." and "Michael Moore..."
      i have on my database several tables : section, categories, subcategories and an article table of course.
      Honw can i do this? a new table?
      Thanks in advance for the answers
        • 1. Re: How to create "related articles"?
          Günter Schenk Level 4
          Hi Thierry,

          "related articles" could be assigned by adding an extra (varchar) column like "related_articles_id", which stores the Primary Key(s) of whatever related articles as Comma Separated values -- in order to create a list of "related articles" to choose from, I suggest to give ADDT´s "Comma separated Checkboxes" behaviour a try.

          Cheers,
          Günter Schenk
          Adobe Community Expert, Dreamweaver
          • 2. Re: How to create "related articles"?
            Level 1
            Hi Günter, thanks for your answer.
            But just to be sure, i have to create another table to store the related articles and then link this table to my article table with a "related_articles_id" foreign key?
            I'll give a try and feedback, thank you very much
            Cheers
            • 3. Re: How to create "related articles"?
              Günter Schenk Level 4
              Hi Thierry,

              ------
              But just to be sure, i have to create another table to store the related articles and then link this table to my article table with a "related_articles_id" foreign key?
              ------

              not at all, it can be a column in the very same table, which (that´s where your "Comma separated Checkboxes" recordset comes into play) is meant to hold the Primary Key(s) of other articles -- except the one you´re currently editing of course, so you will have to exclude the current article´s Primary Key from the recordset that´s driving the "Comma separated Checkboxes" behaviour.

              TIPP: make sure that the "Comma separated Checkboxes" behaviour only exists on the Update Record form, as an Insert Record form has no clue of the to-be-inserted Primary Key

              I actually did the very same for my ADDT tutorial site, and it´s pretty easy

              Cheers,
              Günter Schenk
              Adobe Community Expert, Dreamweaver
              • 4. Re: How to create "related articles"?
                Level 1
                Hi Günter, first of all, many thanks because i follow your instructions, very useful, it works!
                But i still have a problem, i don't know how to display my related articles.
                In fact, on my homepage, i have two types of articles, "main articles" and "secondary articles", two recordsets for each and of course a repeated region for each recordset.
                How can i display the related articles in the corresponding article? i try to make a recordset but i already have repeated regions?
                Thanks in advance
                Cheers.
                • 5. Re: How to create "related articles"?
                  Günter Schenk Level 4
                  Hi Thierry,

                  at times I use to help myself by using some sort of "sub query" like the following:

                  --------
                  $query_related_articles = "SELECT id, headline FROM tut_article_main WHERE id = '".$row_mainquery['id']."' AND active = 'Y'";
                  $related_articles = mysql_query($query_related_articles, $conn) or die(mysql_error());
                  $row_related_articles = mysql_fetch_assoc($related_articles);
                  $totalRows_related_articles = mysql_num_rows($related_articles);
                  -------

                  ...in other words, it´s a type of query which internally points to an existing one: WHERE id = '".$row_mainquery['id']."'

                  All you´d usually have to do, is to manually add a do/while loop (which is in fact a "repeat region") to the document, which refers to that sub query -- and that should also work within an existing repeat region, though I didn´t try that myself do far:



                  - related articles headline 1
                  - related articles headline 2
                  - related articles headline 3
                  ......



                  This sub query will have to be "closed" at the end of the document like the regular DW queries, example:

                  mysql_free_result($related_articles);

                  It may well be that DW will not display a sub query in the behavious panel, as such a thing doesn´t conform to what DW understands as regular query -- it´s all experimental, so please backup the original document first.

                  Cheers,
                  Günter Schenk
                  Adobe Community Expert, Dreamweaver
                  • 6. Re: How to create "related articles"?
                    georgev63 Level 1
                    Thierry, I think the most efficient way to display your CSV's in a repeat region is to start out by saving the related articles by their names instead of their ids in your "main articles" table. That way you can just display the related articles as they are stored in your table (ie. Article1, Article2, Article3,...) without having to resort to nested repeats. If you need to replace the commas with a different separator just run

                    You might also want to take a look at this article.