This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Hi there,
I am trying to add a category and also category_slug to a post.
I have been able to use the belongsto to link the list of categories to the post. Also in fields.yaml I have
category:
label: Category
type: relation
nameFrom: category_name
span: right
Which populates a dropdown that fetches the list of categories from the categories table.
My issue I would like to have a relation to the category_slug also. It can get the id of the category from the relationship but I want it to fetch the category_slug so I can only list those posts that are equal to the category the user has selected. My tables are
acme_item_posts
acme_item_categories
The way I am doing this is that I make 3 CMS pages with the components post, posts and categories.
The categories component list the categories. The posts component lists the post from the selected category from the url :slug and the post will be the actual post_id from the selected post. Is there any simpler way of doing this? I want a page to list categories, then link the posts which belong to that category. The links to the individual posts from that category. How do I do this in October?
Hi,
do not reinvent the wheel.
RainLab Blog plugin has exactly the functionality you described here.
http://octobercms.com/plugin/rainlab-blog
Just review the codebase if this is for educational purpose.
It does but to modify it would take longer than what i'm trying to do, plus it won't be for educational purposes. But thanks for the reply anyways.
I had a look at the new visual builder which looks fantastic but still, categorising a group of objects seems so difficult. Almost all real world examples will require sorting. I have done everything up to linking urls to the categories like in the blog plugin. Looking at the blog plugin it seems to have both cat_id and post_id in a separate table?
I have made a relationship with posts to category. It knows what category_id a post belongs to, but as for structuring CMS pages and components to pass in url helpers, i'm so stuck :S
1-3 of 3