nikola Posted July 13, 2012 Share Posted July 13, 2012 I'm trying to fetch articles based on category selection. I have the following setup: CategoryCategory 1Subcategory 1Article 1 Article 2 Article 3 [*]Subcategory 2 Article 1 Article 2 Article 3 [*]Subcategory 3 Article 1 Article 2 Article 3 [*]Subcategory 4 Article 1 Article 2 Article 3 [*]Subcategory 5 Article 1 Article 2 Article 3 [*]Category 2 Subcategory 1Article 1 Article 2 Article 3 [*]Subcategory 2 Article 1 Article 2 Article 3 [*]Subcategory 3 Article 1 Article 2 Article 3 [*]Subcategory 4 Article 1 Article 2 Article 3 [*]Subcategory 5 Article 1 Article 2 Article 3 I've made "categories" field with a type of: "Page" where I select Category as parent for categories. All articles have the same template - "article". I want to add categories to Page reference field assigned to "article" template so I can pull them on the front end. Let's say I want to add articles on front end from Category 1 - Subcategory 1, Category 2 - Subcategory 1, Category 2 - Subcategory 3 that use the same template - article and have same categories set in the categories Page reference field. Link to comment Share on other sites More sharing options...
ryan Posted July 13, 2012 Share Posted July 13, 2012 I'm not sure that I understand the question? But you did say that you want a categories Page reference on the article template. That makes me think that you probably don't want the articles structured under the subcategories and instead maybe they should all be under /articles/ ? Then you'd select categories/subcategories from the Page reference field using something like PageListSelectMultiple or PageAutocomplete. That would at least solve the issue of articles that need multiple categories/subcategories (though not sure if this is something you needed or not?) Link to comment Share on other sites More sharing options...
nikola Posted July 14, 2012 Author Share Posted July 14, 2012 That would solve my problem and would be easier (having articles under one page and reference them through the Page categories field), but can it be accomplished by keeping the structure above? Link to comment Share on other sites More sharing options...
ryan Posted July 16, 2012 Share Posted July 16, 2012 If you keep the structure above, then you would consider the parent ($page->parent) to be the 'primary sub-category' and the grandparent ($page->parent->parent) to be the 'primary category'. In that case, you'd probably want to consider your categories page reference to be 'secondary categories'. I think this structure works fine if you consider the primary category/subcategory to be mostly static once published and more important than the secondary ones. Link to comment Share on other sites More sharing options...
nikola Posted July 16, 2012 Author Share Posted July 16, 2012 I haven't thought of that, will try that Ryan! Categories and subcategories are static and they all have relations like they have been set up ih the back end. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now