stephenjbell

dotCMS - Use multiselects in widget to pull cat. content

Jul 20th, 2011
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.90 KB | None | 0 0
  1. #set ($maxTitleLength = 55)
  2. #set ($newsItemsPerColumn = 4)
  3.  
  4.  
  5. ############## Categories from widget ##################
  6.  
  7. ## Get the categories from the multiselects used when the widget was put into the page,
  8. ## then format them for use in a query
  9.  
  10. #### AUDIENCE
  11.  
  12. ## If no audience is specified for the widget, show ALL audiences' stories
  13. #if($audience.size()>0)
  14. #set($audienceQuery = "+(")
  15.  
  16. #foreach($categoryInode in $audience)
  17. #set($audienceCat = $categories.getCategoryByInode($categoryInode))
  18. #set($audienceQuery = "${audienceQuery}categories:${audienceCat.categoryVelocityVarName} ")
  19. #end
  20.  
  21. ## End with a closing parenthesis
  22. #set($audienceQuery = "$audienceQuery)")
  23.  
  24. #end
  25.  
  26.  
  27. #### DEPARTMENT
  28.  
  29. ## If no department is specified for the widget, show ALL departments' stories
  30. #if($officesservicesdepartments.size()>0)
  31. #set($departmentQuery = "+(")
  32.  
  33. #foreach($categoryInode in $officesservicesdepartments)
  34. #set($departmentCat = $categories.getCategoryByInode($categoryInode))
  35. #set($departmentQuery = "${departmentQuery}categories:${departmentCat.categoryVelocityVarName} ")
  36. #end
  37.  
  38. #set($departmentQuery = "$departmentQuery)")
  39.  
  40. #end
  41.  
  42. #### FEATURE LEVEL
  43.  
  44. ## If no feature level is specified for the widget, show ALL levels' stories
  45. #if($onlyFeaturedContentFor.size()>0)
  46. #set($featureQuery = "+(")
  47.  
  48. #foreach($categoryInode in $onlyFeaturedContentFor)
  49. #set($featureCat = $categories.getCategoryByInode($categoryInode))
  50. #set($featureQuery = "${featureQuery}categories:${featureCat.categoryVelocityVarName} ")
  51. #end
  52.  
  53. #set($featureQuery = "$featureQuery)")
  54.  
  55. #end
  56.  
  57.  
  58.  
  59. ############## Generate the listing ##################
  60.  
  61. #set($ocNewsQuery = "+structureName:OcNews +live:true +working:true $!audienceQuery $!departmentQuery $!featureQuery")
  62.  
  63. <!--$!{ocNewsQuery}-->
  64. <section class="newslist ocnews" data-count="$dotcontent.count($ocNewsQuery)" data-itemspercolumn="$newsItemsPerColumn" data-currentul="1" data-ocnewsquery="$UtilMethods.encodeURL($!ocNewsQuery)">
  65. <div class="newsboxtitle">
  66. <h3><a href="/news">$!displayTitle</a></h3>
  67. <a href="/news/rss-feed.html?title=$!UtilMethods.encodeURL($!displayTitle)&query=$!UtilMethods.encodeURL($!ocNewsQuery)" class="rssbutton" title="OC News RSS Feed">$!displayTitle RSS Feed</a>
  68. </div>
  69. <a href="#scrollup" class="scrollup inactive">Newer Stories</a>
  70. <div class="newslistholder">
  71. <div class="newslistmover">
  72. <ul>
  73. #dotParse("/lucid/ochome/widgets/ocnewsul.vtl")
  74. </ul>
  75. </div>
  76. </div>
  77.  
  78. <a href="#scrolldown" class="scrolldown active">Older Stories</a>
  79. </section>
  80.  
  81. ## Reset all variables to not interfere with multiple instances of widget
  82. #set ($maxTitleLength = "")
  83. #set ($newsItemsPerColumn = "")
  84. #set($audienceCat = "")
  85. #set($audienceQuery = "")
  86. #set($departmentCat = "")
  87. #set($departmentQuery = "")
  88. #set($featureCat = "")
  89. #set($featureQuery = "")
  90. #set($ocNewsQuery = "")
Advertisement
Add Comment
Please, Sign In to add comment