0

I used this link: Hide content of blog posts when displaying blog post list in OctoberCMS?

as a tutorial to create a new plugin and show my blog posts by my own style (just post title, date, etc)

But now I need to show the full content of the post. I've migrated from wordpress, where each post creates a new page automaticaly. Does OctoberCMS do the same thing? If yes, how can I relate the post title to the post page. (if not I'll create a "read more" link and show the content on the same page, but, if the users get redirect to the post page, it would be great!)

thanks! Regards

1 Answers1

1

October CMS is not like word-press, To make posts you need actual plugin and with in that plugin you can add models/tables for you post data

Then you need to create components which can show your records to front-end.

If you are not using rainlab-blog plugin then you need to do this stuff

So basically you need to create this things :

Page where you want to list all post and then add listposts component which will show list of posts (you need to make it manually) then for that component you need to pass single post detail page

For single post again you create new page add another component which can read slug and show respective post data

For redirection from post list to single post you need to create link as you are passing single post detail page to component you can create link with slug and redirect to single post page

For better reference check out https://octobercms.com/plugin/rainlab-blog plugin and read its documentation and code

Then you understand how things works.

Its kind of pain to do thing manually as you are coming from wordpress, But it will give you more control and more flexiblity

Once you made your plugin you can fully Extend it and reuse it as you want.

if any doubt please comment.

Hardik Satasiya
  • 9,547
  • 3
  • 22
  • 40
  • 1
    Hardik, thanks for your response! I'll read all that documentation. – Marcos Rodrigo Jung Alves Feb 06 '18 at 17:57
  • yes, if find any difficulties you can ask :) , october CMS more like MVC, where `components` are `VC` (view controller) at front side and plugin models are `M` (model) – Hardik Satasiya Feb 06 '18 at 17:58
  • 1
    I've migrated from wordpress to october exactly because of the "freedom of control and more flexibility" that octoberCMS offers. But just with your answer I got the idea on how to do it. thanks again! Best Regards – Marcos Rodrigo Jung Alves Feb 06 '18 at 18:03
  • welcome mate, you will get freedom you seek :) for sure – Hardik Satasiya Feb 06 '18 at 18:08
  • 1
    I'm usually very lazy to watch tutorial videos (I do prefer to read tutorials, hehehe)... but... that tutorial video on RainLab's Blog Plugin, maaaaan, it's very enlightening. Thanks! I'll post here the results when I finish it. – Marcos Rodrigo Jung Alves Feb 07 '18 at 16:52
  • Hardik, hello again! hehehe... I'm just having a hard time now on how to hide the posts that are not flagged as "published". I have two post created but both are not published (those posts are just for test, and I'll keep one of them as a model, so my wife can use it to post new content, as she doesn't know anything bout html) thanks again! – Marcos Rodrigo Jung Alves Feb 08 '18 at 12:34
  • you are using `rainlab-post` plugin or custom bulid one ? – Hardik Satasiya Feb 08 '18 at 12:55
  • I'm using a custom one. I'm trying to edit my default.htm. It is like this: https://jsfiddle.net/mrodrigoja/n93ettmr/ – Marcos Rodrigo Jung Alves Feb 08 '18 at 13:36
  • tryed to add {% if post.isPublished() %} right below {% for post in posts %} but it didn't work – Marcos Rodrigo Jung Alves Feb 08 '18 at 13:37
  • `{% if post.isPublished() %} ...code... {% endif %}` this should work, and your `post model` should have method `isPublished` and it should return `true` or `false` – Hardik Satasiya Feb 08 '18 at 14:01
  • 1
    Well... so... I've deleted the posts and created another one called "tutorial". This one I didn't checked the "published" flag... and now it stays hidden... I don't know what happened.... But it's working now. So... thats good! Hardik, thanks again for all your help. May you have a "Happy Carnaval", hehe. Regards! – Marcos Rodrigo Jung Alves Feb 08 '18 at 16:15