![]() |
Search:
|
Page last modified 17:24, 3 Nov 2011 by tehmina.khan
Template:Hide Elemments of a page > FilesForHidding - do not work properly in Beech > Template:HideElements
Template:HideElementsTable of contentsNo headers// HideElements works for skin Fiesta only // by neilw, 2009-2011 // // 1.10 3/22/2011 neilw - added "ratings" option to hide page ratings // - accepts a single string arg rather than a list of one item // 1.00 8/3/2009 neilw first release // // Usage: HideElements(elements, byuser) // elements: list of strings OR "all". If list of strings, each indicating an element to hide: // "tags" page tags // "files" list of attached files // "images", gallery of attached images // "comments", comments at bottom of page // "ratings_top" page ratings at top right corner of page // "ratings_bot" page ratings at bottom of page // "ratings" page ratings at top and bottom of page // "all" all of the above // byuser: hide the above elements only for users without write permission on the page // // Tina Says - example as follow : // HideElements('all')- hide all the elements all the time // HideElements( 'files', true)- hide one element some of the time // HideElements( ['files','images','tags'], true)- hide multiple elements all of the time // // The template takes two arguments: // HideElements() // HideElements(elements, byuser) // // This Template works in the Fiesta skin - but so far has not work in the Beech skin 15/10/2011 // var allowed_elements = { tags: "div.pageInfo", files: "div.file", images: "div.gallery", comments: "div#comments", ratings_top: "div#deki-page-rating-bar", ratings_bottom: "dd.pageRatings,dt.pageRatings", ratings: "div#deki-page-rating-bar,dd.pageRatings,dt.pageRatings" }; var elements = $0 ?? $elements; if (elements is not list) let elements = [ 'all']; var byuser = $1 ?? $byuser ?? true; var selectors = []; var errors = []; foreach (var e in elements) { if (e == "all") { let selectors = list.select(map.values(allowed_elements), "string.indexof($,'_')<0"); break; } else if (e is not str || !#allowed_elements[e]) let errors ..= [ e ]; else let selectors ..= [ allowed_elements[e] ]; } <html> if (#selectors && (!byuser || !wiki.pagepermissions().update)) { <head> <style type="text/css"> string.join(selectors, ",").."{ display:none; }" </style>; </head>; } if (#errors) { <body> <div> "ERROR: HidePageElements: bad element(s): " .. string.serialize(errors) .. "; allowed elements are:"; <ul> foreach (var ae in map.keys(allowed_elements)) <li> ae </li>; </ul>; </div>; </body>; } </html>; |
|
Powered by MindTouch Core |