Is there a way to count the number of children of each type within the children control? $TotalItems just gives the number of types of children, which is not what I'm looking for.
An example would be if you had links to genres of movies in a Children control showing comedies, action films, and westerns. $TotalItems would print 3, but I don't want to know how many genres of movies there are in the database; I want to know how many there are of each one e.g. comedy (5), action (9), western (3).
Ah, well the genres were just an example. What I've got is this:
A pagetype ActionPage, with pages like "removal from library," "restriction of access," etc. These are held in ActionHolder.
ActionHolder uses % control Children % to list the titles of each page and link to them. Beside the title I'd like a count of how many of each type there are (e.g. removal from library (6), restriction of access (11)).
$Title and $Link are working as expected (they change each time), but after them $TotalItems always gives (14), which isn't what I wanted. $Count within % control Children % is always blank.
Does that make sense? I feel like this probably has a simple answer and I'm just not seeing it.
I realized why this isn't working, and it's not working because I'd forgotten how it's all set up on the backend.
On any given ArticlePage you can check a box for Actions (corresponding to ActionPages), so I'm actually trying to do two different things at once: on ActionHolder, list and link to the Children. Also, count how many times each of those Children appear in an entirely different table.
Could I maybe write a function to count, with $this->ID as a variable to be put into the SQL, and use that function within Children? Or is it more complicated than that?
No, they're arranged like this:
with a many_many between them.
I figured it out, though. I wrote a function to count what I needed, and it worked once I moved it out of ActionHolder.php into ActionPage.php (since I was trying to call it in the control Children on the page ActionHolder).