Announcement

Collapse
No announcement yet.

Theme customization: how to display text posts in KVS

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Theme customization: how to display text posts in KVS

    KVS Ultimate edition provides Posts module that can be used for extending KVS functionality in many ways:

    - Displaying any structured textual data, such as news, stories, blog posts.
    - Collecting information from members, such as validation documents.
    - Connecting additional items to videos and albums, for example reviews.
    - Extending KVS data structure to additional data types.

    In order to use posts, one should first create a post type. All posts of the same type have the same data structure and they can be customized with different sets of custom fields in Settings -> Customization section. That's why posts are so powerful customization feature.


    How to use text posts in KVS

    KVS default theme provides basic support for text posts: ability to render lists of specific post types and view pages for them. Here are basic steps to get this info displayed.

    1) Create a post type in Posts section of admin panel:

    Click image for larger version

Name:	new_post_type.png
Views:	398
Size:	13.6 KB
ID:	1149

    NOTE: it is not required to have External ID being similar to URL pattern, but if possible it is recommended to have them similar for better routing understanding.

    2) After creating a post type you can start creating posts of this type. Under Posts section in admin panel you should now see ability to display all posts of News type and create new posts of News type.

    3) In .htaccess file in the root folder of your project you can find the following sample RewriteRules designed for news post type:

    Code:
    # posts example --------------------------------------------------------------------------------------------------------
    
    RewriteRule ^news/$                     posts_list.php?post_type=news [L,QSA]
    RewriteRule ^news/([0-9]+)/$            posts_list.php?post_type=news&from=$1 [L,QSA]
    RewriteRule ^news/([0-9]+)/([^/]+)/$    view_post.php?id=$1&dir=$2 [L,QSA]
    RewriteRule ^news/([^/]+)/$             view_post.php?dir=$1 [L,QSA]
    Duplicate these rules for your new post type, if it has another URL pattern or external ID. Replace the first part of RewriteRule with your post type URL pattern (^news/) and replace the last part of RewriteRule with your post type external ID (?post_type=news).

    Access your post list from the given URL. If RewriteRules are set up correctly, you will see list of your posts with clickable links to their view pages:

    Code:
    https://www.kvs-demo.com/news/
    4) If you need to change design of post list or post view pages, please find them in Website UI section of admin panel:

    Click image for larger version

Name:	post_pages.png
Views:	222
Size:	12.1 KB
ID:	1150

  • #2
    Can you give an example of how we could create a page for users to submit validation documents?

    For example, filling in text fields and uploading documents like an image or file?

    Comment


    • #3
      It looks like file upload is not supported for members in post_edit block, we added this to our todo list.

      In order for members to submit text data, here are the steps:

      1) In Posts -> Post types create a new post type for users to submit their documents. For example until file upload is not supported for this type of data, users can upload their files to Google docs and provide a link instead. In Settings -> Customization settings enable custom text field 1 for this post type.

      2) Go to Website UI -> Pages and create a new page with the following block in page template (page template also needs to contain other code that will render header and footer, it depends on the theme and can be taken from any other page, for example 404):
      HTML Code:
      {{insert name="getBlock" block_id="post_edit" block_name="Post Edit"}}
      3) After saving new page, you will see Post Edit block appeared for this page, open it for editing.

      In block parameters specify post_type value, which should exactly match the External ID of the post type you created in #1.

      In template code you need to specify template for this block. It can be copied from the Show default template link above the field. Default template for post_edit block renders title, description, content, categorization and custom text 1 fields. Some of these fields are mandatory (title and content) and can't be removed from template. Just replace them with hidden inputs that contain some predefined texts, if you don't want user to specify something unique there e.g.:

      HTML Code:
      <input type="hidden" name="title" value="Validation documents for {{$smarty.session.username}}"/>
      <input type="hidden" name="content" value="Validation documents for {{$smarty.session.username}}"/>
      Other fields that are not needed for this task can be removed from block template.

      4) After saving block changes, you will be able to access this page via its external ID:
      Code:
      http://domain.com/page_id.php
      Since this page renders post_edit block that requires user to be logged in, if you are not logged in as a valid user, this page should redirect you to login page:
      Code:
      http://domain.com/?login
      If you are logged in, you should be able to see form with custom text field and other fields you have in block template. Submitting this form should result in creation of new post of this new type.

      Comment


      • #4
        thanks, I have created "news" but from admin I get an error:
        File not found. url: /admin/posts_for_news.php

        or:
        admin/posts_for_news.php?action=add_new File not found.

        Comment


        • #5
          It looks like your project doesn't have Apache installed. If this is true and you have only nginx and nginx rewrites, please make sure you followed step #4 from this guide:
          https://forum.kernel-video-sharing.c...tes-into-nginx

          E.g this one:

          4) Add the following rewrite rules into main domain nginx config under server block:

          Comment


          • #6
            Originally posted by Tech Support View Post
            It looks like your project doesn't have Apache installed. If this is true and you have only nginx and nginx rewrites, please make sure you followed step #4 from this guide:
            https://forum.kernel-video-sharing.c...tes-into-nginx

            E.g this one:

            thanks,

            .htaccess I use the file and it works fine, I have nginx but I have created new pages and I have created new rules in .htaccess and they work on the web.
            without touching ngnix.

            I'm going to see if there is any other problem.

            Comment


            • #7
              (the problem is that the file does not exist: posts_for_news.php, from the files I received from kvs )

              Comment


              • #8
                Originally posted by davex View Post
                (the problem is that the file does not exist: posts_for_news.php, from the files I received from kvs )
                This file indeed doesn't exist, this is handled by dynamic rewrite in /admin/.htaccess:

                Code:
                RewriteRule ^posts_for_(.*)\.php$ posts_for_types.php?post_type_external_id=$1 [L,QSA]

                Comment

                Working...
                X