SID-01150: Dynamically generate page displaying attachment
| Status: |
Answered |
TWiki version: |
5.0.0 |
Perl version: |
5.8 |
| Category: |
CategoryTemplates |
Server OS: |
Redhat |
Last update: |
15 years ago |
Hi, I have a question. I maintain a programming site and publish a lot of code I have written to it. I would like to be able to dynamically create pages that display this code, rather than having to create static pages for each program I write.
Currently, I have to create a static page and include the following directive that looks something like this:
%CODE{"java"}%
%INCLUDE{"%ATTACHURL%/MyClass.java"}%
%ENDCODE%
which displays the code in the attached file MyClass.java
My question is this: is there a way to do this dynamically, e.g. create a template or something else to which I can just pass MyClass.java in a hyperlink so that when I click on it, the resulting page generated is equivalent to the static page?
Any pointers would be greatly appreciated.
FemiByte
--
AnthonyOlufemi - 2011-04-16
Discussion and Answer
1. Create a custom template page that has the following:
%CODE{"java"}%
%URLPARAM{code}%
%ENDCODE%
2. Create a page that has an HTML form with a text field named
topic and a textarea named
code calling the save script.
This allows you to create a named page based on code pasted code into the textarea.
Details in
TWikiTemplates.
--
PeterThoeny - 2011-04-18
Closing this question after more than 30 days of inactivity. Feel free to reopen if needed. Consider engaging one of the
TWiki consultants if you need timely help. We invite you to
get involved with the community, it is more likely you get community support if you support the open source project!
--
PeterThoeny - 2011-06-16
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.