how can i get latest news from two or more document sources path

mmm mmmm asked on May 10, 2014 06:31

how can i get latest news from two or more document sources path. if i had 2 paths like : /activities/News/% and the other path is /general/News/%

i tried to put the document sources in content path separated by (,) or (;) but it is not worked like this example: /activities/News/% ; /general/News/%

Recent Answers


Brenden Kehren answered on May 11, 2014 14:44

How about looking at it a little differently, place the news in a central place and categorize the news items. Then on your general page, look for all News items categorized as general. That's kind of the point of a CMS, centralized location for content.

The other alternative would be to create a custom query on the News doc type with a UNION statement for the two different locations then use a custom query repeater or data source and display them on your page.

0 votesVote for this answer Mark as a Correct answer

Richard Sustek answered on May 12, 2014 01:11

Hi,

I would also like to add that the easiest solution is to use two of your webpart next to each other so that you can set each to a different path.

0 votesVote for this answer Mark as a Correct answer

Development Support answered on July 1, 2014 09:33

You can specify two locations using the WHERE condition of the repeater, using the below format:

(DocumentNamePath LIKE '/MyPath1/Events/%' OR DocumentNamePath LIKE '/MyPath2/Events/%')

If you wish to make this a little easier for users, you can copy the Repeater webpart, add a "PathTwo" field to it, and modify the repeater configuration with the below code:

            // Select 'all' items, since filtering by Where using path 1 and path 2
            repItems.Path = "/%";

            // Compile Paths
            string newPath = CMS.MacroEngine.MacroContext.GlobalResolver.ResolvePath(Path);
            string newPathTwo = CMS.MacroEngine.MacroContext.GlobalResolver.ResolvePath(PathTwo);

            // Compile While Statement, if there is a % at the end then should handle fine.
            string whileStatement = "(DocumentNamePath LIKE '" + newPath + (newPathTwo.Length > 0 ? "' OR DocumentNamePath LIKE '" + newPathTwo + "'" : "") + ")";

            // If existing where condition, append it.
            repItems.WhereCondition = (WhereCondition.Length > 0 ? WhereCondition + " AND " : "")+whileStatement;
0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.