Advertisement
Guest User

CMS API

a guest
Nov 26th, 2014
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.79 KB | None | 0 0
  1.  
  2. <!--
  3. When a blog post is added to the CMS, the content is saved to an html file to be called when the post needs displayed. the rest of the data, like the title, tags and date, are stored in such format:
  4.  
  5. { name: "hello world", date: 1417004002173, tags: ["testing","this","stuff"] }
  6.  
  7. This data is called in the post.html file that specifies how the post is displayed like so:
  8. -->
  9.  
  10. <html>
  11.     <head>
  12.         <title>
  13.             Xymon.IO - <node>POST.NAME</node>
  14.         </title>
  15.     </head>
  16.     <body>
  17.         <h1><node>POST.NAME</node></h1>
  18.         <h2>Posted <node>new Date(POST.TIME)</node></h2>
  19.         <article>
  20.             <node>POST.CONTENT</node>
  21.         </article>
  22.     </body>
  23. </html>
  24.  
  25. <!--
  26. There is a post.html file tied to each individual blog created, so each blog can have a completely different look. To keep each blog as customizable as possible, there is a POST.DATA object that contains custom data specified when the blog was posted. This way, you can add your own data that is exclusive to that blog, and may not be in any other blog posts.
  27.  
  28. For example, let's say you want to tie an image to each post in a specific blog; you could create POST.DATA.ICON.
  29. -->
  30.  
  31. <html>
  32.     <head>
  33.         <title>
  34.             Xymon.IO - <node>POST.NAME</node>
  35.         </title>
  36.        
  37.         <!--Is ICON in the custom data?-->
  38.         <node>
  39.        
  40.             var imgsrc;
  41.        
  42.             if(POST.DATA.ICON) {
  43.            
  44.                 // It exists!
  45.                 imgsrc = POST.DATA.ICON
  46.            
  47.             } else {
  48.            
  49.                 // It doesn't exist, return a definate error image.
  50.                 imgsrc = "http://xymon.io/error.png"
  51.            
  52.             }
  53.        
  54.         </node>
  55.        
  56.     </head>
  57.     <body>
  58.         <!--Here's where we'll use it.-->
  59.         <img src="<node>imgsrc</node>" />
  60.         <h1><node>POST.NAME</node></h1>
  61.         <h2>Posted <node>new Date(POST.TIME)</node></h2>
  62.         <article>
  63.             <node>POST.CONTENT</node>
  64.         </article>
  65.     </body>
  66. </html>
  67.  
  68. <!--
  69. The possibilities are endless.
  70. -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement