Jump to content

Theme customization: how to display text posts in KVS


Tech Support

Recommended Posts

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:

new_post_type.png.985e76c5532ea7ecce9fe43bf8c16d85.png

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:

# 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:

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:

post_pages.png.f4fcea3fee8c75f1bec93f1e2cd2b3c8.png

 

5) In order to add menu item, edit Website UI -> Page components -> include_header_general.tpl template. Find this UL node (the example is for default theme, other themes may have another UL syntax):

<ul class="primary">
  ...
</ul>

And add the following list item (LI) to it at the desired position:

<li {{if $storage.list_posts_common_posts_list.post_type_info.external_id=='news'}}class="selected"{{/if}}>
<a href="{{$config.project_url}}/news/">News</a>
</li>

 

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...

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):

{{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.:

<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:

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:

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.

Link to comment
Share on other sites

  • 1 month later...

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.com/forum/educational-support/educational-series/315-how-to-move-apache-rewrites-into-nginx

 

E.g this one:

 

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

 

Link to comment
Share on other sites

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.com/forum/educational-support/educational-series/315-how-to-move-apache-rewrites-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.

Link to comment
Share on other sites

davex said:
(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:

RewriteRule ^posts_for_(.*)\.php$ posts_for_types.php?post_type_external_id=$1 [L,QSA]
 
  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...