Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

4 Neutral

About ratna

  • Rank
  1. I used float fields in the person template for each category before. But because a person can have multiple results for the same category and because the categories should be extensible, I switched to using a repeater field that combines a select options field for the category and a float field for the result. The category variable uses the number that was assigned to that category in the select options field, e.g. 1=Category 1 2=Category 2 ... The code works and it iterates though all the people, but the sort order is not correct and seems to depend on the order of the repeater fields, rather than on the value. Unfortunately, the issue with the redundant and verbose queries to retrieve simple values remains as well.
  2. Yes, @szabesz, I've read everything I could find about repeaters but no combination seems to work. It's a very simple SQL query, so it seems to me this should be possible. SELECT * FROM people LEFT JOIN categories ON (people.id = category.person_id AND category.type = 1) ORDER BY category.value DESC GROUP BY people.person;
  3. I'm a little stuck again. In order to reduce the amount of fields, and because each result shares certain fields, I implemented a repeater field for the results of each person. The repeater field combines the category (select option) and a value (float). Each person can have none, one or multiple entries for each category. I've now been trying for several hours to display a sorted results table for each person in a certain category to no avail. $people = $pages->find("template=person, results.category={$category}, sort=-results.value"); This doesn't work properly. The idea is to get all people with one or more results for the given category and sort them by the highest value they have in the repeater field for that category. Now, my next gripe is that, even if this worked properly, I pretty much have to repeat that selector when I loop through the people array to get the highest value within the repeater field. foreach ($people as $person) { $person->results->get("category={$type}, sort=-value")->value; } This seems a little verbose and inefficient. Is this a limitation or am I doing something wrong?
  4. Thanks, i just implemented it and it works perfectly. Third day into PW and I'm already sold for good 🙂 Thinking about it, I actually find it useful to use the parent pages to display the available sub-categories, so it's a win-win. I ended up using the following structure: Home |-- People |-- Person 1 |-- Person 2 |-- ... |-- Categories |-- Category 1 |-- Category 2 |-- ... People and children are hidden. Each category page uses a "category" template that displays a table with all people that have a populated field for that category. No custom backend required, just the admin interface - loving it.
  5. Thanks for the responses, it makes a lot more sense already. The structure that @kongondo describes seems to be what I need. However, just to double check, let me state again that none of this data will actually be displayed as a page of its own. I merely need a container to hold the data, which I can then query from the actual results page and render as a table. I'm trying to save this data by using the PW pages and fields system, so that I won't have to actually create a custom DB table. For example, the custom DB table that I'd normally make for this would look something like this (not normalized for demonstrative purposes): +----------+------------+------------+------------+ | person | category_1 | category_2 | category_3 | +----------+------------+------------+------------+ | person_1 | 500 | 1000 | NULL | | person_2 | 1000 | NULL | 1500 | | person_3 | 750 | 750 | NULL | +----------+------------+------------+------------+ The results page for category 1 would then query the DB with something like: SELECT person, category_1 FROM results WHERE category_1 != NULL ORDER BY category_1 DESC; The results would then be rendered as a table, listing every person that has an entry in this category. Would this still be a valid usage for pages and fields, even though there would only be one actual, visible page for this simple example (the results page), with the rest of the pages merely being containers that hold data? I guess it's just difficult for someone new to PW to picture something called a "page" as anything other than an actual, visual page.
  6. Hello, first of all, let me thank everyone who is or was involved in this project. I mostly develop for WordPress and I'm sick and tired of this "CMS" - but hey, that's where the money is. For an upcoming personal project, I started looking for something that agrees more with my philosophies and I came across PW. From what I've seen so far, it's exactly how I would design a secure, stable, lightweight and fast CMS. I love the normalized database, the clean folder structure and the simple, yet powerful clutter-free core. I've been digging through the API for the past two days, but I'm still not 100% sure what type of structure would make the most sense for what I'm trying to achieve. Here's a quick rundown of what a typical data set would look like: Results |-- Category 1 |-- User 1 |-- User 2 |-- User 3 |-- Category 2 |-- User 1 |-- User 3 |-- Category 3 |-- User 2 The results page would list the different categories and each category would list all users that have a result in that category. A user can have results in one or more categories, or in none. The data will be manually entered by me, so it doesn't need to be an actual user account, just a unique entry. The user will also receive more arbitrary data for other areas of the website. Now, in WordPress I would make a few normalized custom tables, create a plugin for the data entry on the backend and then display the individual tables via a shortcode that's embedded in the specific category pages, which would be children of the results page. However, from what I understand so far, this shouldn't be necessary with PW and should be solvable without custom tables or code (aside from the template files). The results page would obviously be a page with a certain template and so would the category pages. What I'm not sure about is how I would set up the users and assign them the result data. Do the users have to be pages as well, with a template that includes all possible result types as fields that might be empty or populated? What threw me off when I tested this was the permalink that gets assigned to all pages, which makes me think you're not supposed to use them for things other than actual pages that are displayed. Any input on how to properly solve this simple structure in PW? Thank you!
  • Create New...