SID-01577: Topic parent list customization
| Status: |
Answered |
TWiki version: |
5.1.0 |
Perl version: |
|
| Category: |
CategoryForms |
Server OS: |
Linux 10.04 |
Last update: |
13 years ago |
I wanted to hide TWIKI default pages from index of a web and then even in drop down menu option of "Topic parent" under "create new topic". I have written below script to hide TWIKI default pages in index which is working fine. But im unable to edit "WebCreateNewTopicTemplate" to reflect the changes for "Topic parent". Please help.
<div id="topicList" style="display:none;">
%TOPICLIST%
</div>
<div id=topicsToBeDisplayed></div>
<script>
var topicDiv = document.getElementById('topicList');
var topics = topicDiv.getElementsByTagName('a');
var topicList = document.getElementById('topicsToBeDisplayed');
for(i=0; i<topics.length;i++){
if(!/Web.*/.test(topics[i].innerHTML))
topicList.innerHTML += "<li><a href='" + topics[i].href + "' > " + topics[i].innerHTML + "</a></li>";
}
</script>
Thought the code might be helpful for others.
--
SrihariV - 2012-11-03
Discussion and Answer
I have found the fix for my main question i.e how to hide TWIKI default pages from drop down menu of topic parent while creating new topic. I added the below code to my "WebCreateNewTopicTemplate" file:
%TMPL:DEF{"topicparent"}%
57 <div id="topicList" style="display:none;">%TOPICLIST%</div>
58 <select id='topicparent' name='topicparent' size='10' class='twikiSelect'>
59 <script>
60 var topicDiv = document.getElementById('topicList');
61 var topics = topicDiv.innerHTML.split('\n');
62 var topicList = document.getElementById('topicparent');
63
64 for(i=0; i<topics.length;i++){
65 if(topics[i].indexOf('<') >= 0){
66 var htmlObject = document.createElement('div');
67 htmlObject.innerHTML = topics[i];
68 tag = htmlObject.getElementsByTagName('*');
69
70 if(!/Web.*/.test(tag[0].innerHTML)){
71 topicList.innerHTML += "<option value='" + tag[0].innerHTML + "' > " + tag[0].innerHTML + "</option>";
72 }
73 } else {
74 if(!/Web.*/.test(topics[i].innerHTML))
75 topicList.innerHTML += "<option value='" + topics[i] + "' > " + topics[i] + "</option>";
76 }
77 }
78 </script>
79
80 </select>
Hope this helps others who want to do the same.
--
SrihariV - 2012-11-05
Thanks for sharing this with the TWiki community!
--
PeterThoeny - 2012-11-05
If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.