Show COUNT in Module?

terp

Beta Tester Extraordinaire
I was thinking of expanding my test setup to mirror what I will eventually try to accomplish with Fabrik when I quit screwing around and find the time. ;)

If I were to create links for all 50 states that point to a pre-filtered Fabrik tables with records from the respective state, is it possible to then display the COUNT of the records for that state?

So, for example, I have 5 records for Alabama and 10 records for California. I would like to display a link to the table showing only Alabama records and a link to the same table filtered for California.

...but was just thinking a COUNT would be nice; so, for example, it would look like this:

Alabama (5), California (10), New York (112), Maryland (0), etc, etc...the state name would be the dynamic link and the count would be in the parenthetical.

Does that make sense?

I guess it could be on regular content, rather than a module, but was thinking it would also be nice to have a *flex* pitch in the header like, "We Currently Have 'COUNT' Records in the Database!"

???

Can you dig it? :)
 
I presume this is a 2.0 question.

In 2.0, you could create a table plugin to handle it. Or at least, that's the kind of thing table plugins should be able to handle. We haven't written many table plugins yet, so we might have to add a few plugin locations/methods to the plugins model to achieve it. But the idea would be a 'pre-display' method which did your query (getting the grouped counts from the other table), then a 'headings' and 'row' method to insert your data.

I've also been thinking about a new "Query" element type. This type would basically let you specify a custom query to use to generate the element data, in either form or table view. This would be exactly what you needed for your requirement.

But right now, the only way would be with a table plugin (and as per above, that might need some tweaking of the Fabrik code to achieve).

-- hugh
 
Yes, sir, 2.0 is the future. ;) I didn't want to clutter the beta forums with non-bug thoughts. ;)

Sounds more complex than I thought...was thinking one could simply wrap the text added by hand (i.e., California) with a dynamic Fabrik URL to prefilter the table, then inject some SQL magic to do the COUNT.

...but now that I think about it, getting the query to fire would require more than a simple statement with one of the half dozen SQL commands I know and use. ;)

Danke sch?n! (I just got home from the local Oktoberfest, so got a few drinks in me). :)
 
Are you talking about building a Fabrik table for the 50 states, and adding the number of related records in those states in an additional row?

That's the only way I can think of doing it (with the table plugin), without building your own little J! module to do it. Or maybe it can be done with something like JUMI. But you'd still need to be able to execute a single query to grab the results for all 50 states, store them in an array of some sort, and use that on your links. You wouldn't want to do 50 separate queries.

That's why I'm thinking in terms of a table, with a table plugin to do that initial single query and add a column for the individual state row data returned from it.

-- hugh
 
Yea, it would be 50 queries and a pain in the butt with the 50 links, too...was thinking a little SELECT COUNT(*) FROM Cars WHERE state=california action, but now you got me thinking a table is pareto optimal. :)

Here's a site (I struggled to find one, but see them all the time) with something similar...just the string of linked states:

http://rentalo.com/vacation-rentals/usa/

I was picturing something similar, just with the fancy dancy post counts in the (15)....adding some bling bling to the string of links. :)

[edit] I'm going to find a solution to getting the SQL in a module, but see the point about doing so for 50 queries. For my "We currently have x listings!" it's fine, but for 50+ added queries to the home page and screwing with all the links, well, thank would get ugly quick.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top