stephenjbell

dotCMS - Custom Field code for pulling list of blogs dropdow

Jul 15th, 2011
499
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 1.60 KB | None | 0 0
  1. ##Trick from HTML5 Boilerplate to only load jQuery if it hasn't already been loaded in this page (ie. by another custom field)
  2. ##Load the local version so as not to break HTTPS
  3. <script>window.jQuery || document.write('<script src="/lucid/js/jquery-1.6.min.js">\x3C/script>')</script>
  4. <script type="text/javascript">
  5.    
  6.     ${esc.d}.noConflict();
  7.     jQuery(document).ready(function($) {
  8.    
  9.         /* When page is loaded, copy the hidden field value to the dropdown */
  10.         var initialValue = $("#selectABlog").val();    
  11.         $("#selectABlog_field select").val(initialValue);
  12.    
  13.         /* When new option is selected, copy dropdown value to the hidden field */
  14.         $("#selectABlog_field select").change(function(){
  15.             $("#selectABlog").val($(this).val());
  16.         });
  17.     });
  18.    
  19. </script>
  20.  
  21.  
  22. ## Detect currently logged in user
  23.  
  24. #set ($foundUser = $cmsuser.getUserByUserId($session.getAttribute("USER_ID")))
  25.  
  26. #if($foundUser)
  27.     #set($foundUserMap = $cmsuser.getUserProxy($foundUser).getMap())
  28.     #set($userEmail = ${foundUserMap.emailAddress})
  29. #else
  30.     <p>ERROR: No user found</p>
  31. #end
  32.  
  33. <p>Currently logged in user, <b>$userEmail</b>, has access to:</p>
  34.  
  35. <select>
  36.     <option value="">--</option>
  37.     #foreach($blog in $dotcontent.pull("+structureName:Blog",1000,"Blog.blogTitle"))
  38.             ## Show blog if the currently logged in user's email address is listed with the blog, or if the current user is an admin
  39.             #if($blog.whoCanPost.indexOf($userEmail) > -1 || $cmsuser.isUserRole($foundUser,"CMS Administrator")==true)
  40.                 ##This user can post to that blog!
  41.                 <option value="$blog.blogUrlTitle">$blog.blogTitle</option>
  42.             #end
  43.     #end
  44. </select>
Advertisement
Add Comment
Please, Sign In to add comment